Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop the enter key from submitting form?

Status
Not open for further replies.

rlingen

Technical User
Dec 6, 2000
41
CA
It appears some of my users are pressing the "Enter" key, expecting to advance to the next field in the form, but instead are submitting the form before it has been filled out completely.

Is there any way, without using javascript, of disabling the "submit on enter key" feature of most browsers? The only answer I can think of is to replace the submit button with a submit image, which I would prefer to avoid if possible. (I had problems immediately after the introduction of IE 5.5 with it submitting everything twice if a submit image was used -- as a separate issue, does anybody have an update on that problem?)

Any solution must work for all usual browsers.

I look forward to any help you can offer.

Roy Lingen

 
rlingen,

There are lots of ways to do this with Javascript but I don't know any other way of doing it with HTML apart from the one that you suggested.

Are you not performing any kind of validation on the users input?? Mise Le Meas,

Mighty :)
 
Thanks for confirming my suspicions.

Yes, I am using some validation, but not on all fields, because many are optional.

Roy
 
rlingen,

You could put an onKeyPress action in each form field. Then check if the key pressed was the enter key and if it was then just put the focus on the next form field.

Is there some reason why you don't want to use JavaScript.
Mise Le Meas,

Mighty :)
 
If you're doing validation on some of your fields aren't you already using JavaScript? Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
to tsdragon:

No the form data is being passed to a PERL script. If required fields are not entered, the script returns an "incomplete form, please fill in the following fields" page.

Roy
 
rlingen,

What do you have against JavaScript? It would be much faster to do client side JS validation than to go back to the server and use PERL for the validation.
Mise Le Meas,

Mighty :)
 
The fact that many of my users use older browsers and I have neither the time nor the desire to research and deal with all the compatibility issues between browser platforms I keep reading about.

It may be slightly faster in using the form (which I doubt will be noticed) but it sure won't be faster for me in implementation!

Roy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top