bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

Enter key submits a hidden submit button




Keyboard Navigation
11 years ago
8 years ago


(Reporter: Oliver Frietsch, Unassigned)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [CLOSEME 2010-11-15])



11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv: Gecko/20070713 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv: Gecko/20070713 Firefox/

When pressing the enter key, Firefox attempts to submit the current form. However, it always uses the first submit button found in the HTML code, even if that one is displayed nowhere on screen (e.g. contained in a hidden div).

Reproducible: Always

Steps to Reproduce:
Have a look at this page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
        <form method="get" action="sample.html">
                <input type="text" name="text1" value="Hello World!" />
            <div style="display:none">
                <input type="submit" name="submit3" value="3" />
            <div style="display:none">
                <input type="submit" name="submit2" value="2" />
                <input type="submit" name="submit1" value="1" />
Actual Results:  
Clicking the visible button leads to submit1, using enter in the textbox leads to submit3, even though submit3 is not visible.

Expected Results:  
If just one button is visible, I would expect the browser to submit that one. If there are more of them, I would prefer simply NO actionm over an unpredictable one.

Comment 1

11 years ago
imho this is the intended behaviour, use the first submit as the default choice...  the developer should choice default action and put that as the first submit... At least the solution could be not use any submit if multiple are defined but then you end up without being able to send a form with all hidden submit buttons. 

I'm not sure if it's a valid enhancement or a invalid report.

Comment 2

11 years ago
We have found a case here at Slacker where Firefox is submitting the form on a plain button element...NOT a submit element.  That is definitely a bug.  

The form in question is a login form with a username and password field.  One button, above the text fields, links to a create account function, and the "real" submit button is below the form.  Firefox is not even submitting the form in this case.  It is actually firing the onclick of the first button.  Our fix for this is to remove the offending button from inside the form scope.

As for submitting forms at all when the enter key is pressed, I would argue that this is also a bug...or at the very least a horror story for accessibility and usability.

Browsers should not submit a form unless the user (or developer) specifically indicates that the form should be submitted.  Clicking enter on a text field can not be considered an authoritative "submit" unless it is the one and only field in the form.

Comment 3

9 years ago
Bug is the same is 320234 - https://bugzilla.mozilla.org/show_bug.cgi?id=320234
This bug was reported using Firefox 3.0 or older, which is no longer supported. The bug has also not been changed in over 500 days and is still in UNCO.
Reporter, please retest this bug in Firefox 3.6.10 or later using a fresh profile, http://support.mozilla.com/en-US/kb/managing+profiles. If you still see this problem, please update the bug. If you no longer see the bug, please set the resolution to RESOLVED, WORKSFORME.

This is a mass search of unconfirmed bugs that have no activity on them, so if you feel a bug was marked in error, just remove the CLOSEME comment in the whiteboard within the next month.
Whiteboard: [CLOSEME 2010-11-15]
No reply, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Last Resolved: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.