Skip to main content

Bug Tracker

Side navigation

#7958 closed bug (invalid)

Opened January 12, 2011 07:37PM UTC

Closed February 01, 2011 07:44AM UTC

Last modified March 10, 2012 10:05AM UTC

<form> elements lacking a submit button do not propagate

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone:
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Hi all

Bare with me :P

Consider this form:

<form action="#">
	<input />

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.
Attachments (0)
Change History (2)

Changed January 17, 2011 05:05PM UTC by rwaldron comment:1

owner: → anonymous
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!

Changed February 01, 2011 07:44AM UTC by trac-o-bot comment:2

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!