Closed Bug 390265 Opened 17 years ago Closed 14 years ago

Enter key submits a hidden submit button

Categories

(Firefox :: Keyboard Navigation, defect)

x86
Windows Vista
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: frietsch, Unassigned)

Details

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

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5

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" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head><title>Sample</title></head>
    <body>
        <form method="get" action="sample.html">
            <p>
                <input type="text" name="text1" value="Hello World!" />
            </p>
            <div style="display:none">
                <input type="submit" name="submit3" value="3" />
            </div>
            <div style="display:none">
                <input type="submit" name="submit2" value="2" />
            </div>
            <div>
                <input type="submit" name="submit1" value="1" />
            </div>
        </form>
    </body>
</html>
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.
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.
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.
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.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.