Sometimes, we want to prevent buttons from submitting forms with HTML.
In this article, we’ll look at how to prevent buttons from submitting forms with HTML.
How to prevent buttons from submitting forms with HTML?
To prevent buttons from submitting forms with HTML, we set the type attribute of the button to button
.
For instance, we write
<button type="button">Button</button>
to set the type attribute to button
to stop it from submitting the form that it’s in.
Conclusion
To prevent buttons from submitting forms with HTML, we set the type attribute of the button to button
.