<form action=""> <button>click</button> </form>
The default behaviour of a button inside a form is to submit that form.
How can I disable the submit behaviour of that button?
Just click f12 in your browser, find the submit button in the html, and then remove the disabled ! It will submit the form even if the inputs are empty.
The simplest solution to prevent the form submission is to return false on submit event handler defined using the onsubmit property in the HTML <form> element.
Yes, structurally the submit button needs to be inside a form element for the document to be valid X/HTML.
Add a type="button"
to it:
<button type="button">Click</button>
The types availabe are:
A good reference: https://developer.mozilla.org/en/DOM/HTMLButtonElement
This will disable via javascript
<button onclick='return false'>click</button>
But you can just define the type
<button type='button'>click</button>
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