Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form submits in FireFox when any button on page is clicked

First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button looks like this:

<p>
    <input type="submit" value="Save" />
</p>

I've now added another button to the page with jQuery code attached. It works in IE, but when I test in FireFox the form submits. I tried adding another button, this time with no attached jQuery code and the same thing happens. When the button is clicked, the form submits.

<button id="random-button">Do Nothing</button>

Why does the standard button element submit the form in Firefox?

like image 892
RememberME Avatar asked Mar 19 '10 22:03

RememberME


People also ask

What happens when submit button is clicked?

5. Most HTML forms have a submit button at the bottom of the form. Once all of the fields in the form have been filled in, the user clicks on the submit button to record the form data. The standard behaviour is to gather all of the data that were entered into the form and send it to another program to be processed.

Do forms need submit buttons?

If you don't have any submit button it is acceptable after all it is an element of form tag and if it is not required you may not add it with in form . This will not broke any web standard.

Does the submit button go inside the form?

Yes, structurally the submit button needs to be inside a form element for the document to be valid X/HTML. But visually you can position the submit button anywhere you want with appropriate CSS (float, absolute/relative positioning, etc).


1 Answers

I recall that Firefox defaults a <button> to a submit button. If you use

 <button type="button" id="random-button">Do Nothing</button>

it should solve your problems.

like image 113
seth Avatar answered Sep 22 '22 06:09

seth