Closed Bug 220047 Opened 21 years ago Closed 21 years ago

<button> tag unexpectedly submits form

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: per, Unassigned)

References

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030916 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030916 The <button> element fires a submit to the surrounding <form>. Only a <input type="submit"> should do that. Sample below submits in Mozilla but not in IE .. <html> <body> <h2>Mozilla bug with button element</h2> <p>&lt;button onclick="" &gt;Button&lt;/button&gt;<p> <p>None of the buttons below should submit the form</p> <form onsubmit="alert('submit')";> <button onclick="alert('hi')">alert('hi')</button> <button onclick="alert('hi');return null;">alert('hi');return null;</button> <button onclick="return void alert('hi');">return void alert('hi');</button> </form> </body> </html> Reproducible: Always Steps to Reproduce: 1. See sample in Details. 2. Click on a button. Actual Results: You get the alert for submit. Expected Results: No alert for submit. - No submit... I've seen the same behavior in Mozilla 1.3.1.
The default type of the button is set to "submit". See: http://www.w3.org/TR/html401/interact/forms.html#adef-type-BUTTON Change the type to "button" and you will get the desired effect. INVALID?
Researching this further, according to w3.org Mozilla behaves correctly and IE does not. W3C says the default type should be submit, whereas IE defaults to button. Not A Bug.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
.
Status: RESOLVED → VERIFIED
*** Bug 277250 has been marked as a duplicate of this bug. ***
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.