Categories
HTML

How to prevent buttons from submitting forms with HTML?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *