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?
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.
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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With