Ticket #7958 (closed bug: invalid)
<form> elements lacking a submit button do not propagate
|Reported by:||anonymous||Owned by:||anonymous|
Bare with me :P
Consider this form:
<form action="#"> <input /> </form>
I noticed that pressing enter would not cause my form to submit, which I found odd. So I attached an event handler listening for the enter key to submit the form and that was all good. I tested this in IE, and found that the form submitted twice! It turns out that this is because jQuery normalizes bubbling on the submit event in browsers that don't support it, so when my listener for the enter key picked it up, it submitted the form, and so did jQuery.
The only solution (I can see) is to stop event propagation on the input fields, and manually trigger the submit, which is fine I guess. But enter usually makes forms submit, I knew something was up. It turned out that forms not containing a submit button will not submit when you press enter. The button cannot be hidden by CSS.
Unless <form>s should specifically include a submit button, I assume this is a browser bug.
I made a simple test form with a submit button, and what I discovered surprised me a little (not too much :P). Pressing enter in a text field will cause the submit button's click event to fire! This occurs before the submit event on the form, so returning false will stop the form from submitting. These factors lead me to believe that the listener for the enter key triggers a click on the submit button, and not a submit on the form, which doesn't make sense to me.
I briefly looked at the W3C spec, and all I could find was this:
submit buttons: When activated, a submit button submits a form. A form may contain more than one submit button.