Forum Moderators: open

Message Too Old, No Replies

Enter key for submit

when it is it automatic?

         

txbakers

3:34 am on Jan 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I ran into an unusual thing tonight.

I have a simple form with a submit button. Usually pressing the Enter key on the keypad submits the form. But in this case it doesn't. The button has to be in focus for that to happen. (Or it has to be clicked).

I don't remember coding anything differently on this form.

Is there some guidelines about when the Enter key works and when it doesn't?

The form is on a popup window, called via jscript on the window.open command. Does that matter?

BlobFisk

6:05 pm on Jan 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wonder if you have stumbled on one of the more bizarre browser inconsistencies here!

It is said that to submit a form using the return key it should have only one text input (<input type="text" ... >) and no textarea (as you can hit return here and it drops the cursor down a line). The W3C is vague but does say the the enter key activates a selected element. (Green text at the end of this section [w3.org]).

The most surefire way of ensuring the behaviour you want, be it enter submitting or not submitting the form, is to use a script to sniff for the enter keypress on the form and do or not do its thing!

HTH

txbakers

8:40 pm on Jan 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess I'll have to try it on different machines/browsers.

On every other page it works forme with the enter key, but this one doesn't submit the form. ODD.