Prevent HTML button from submitting form

HTML buttons by default submit the form they are inside. But what if you need to have a button inside a form (e.g. for Javascript functionality) and you don’t want it to submit the form? The answer is simple: type="button".

<button type="button">Do something</button>

source: W3Schools Button Type Attribute

About Steve Hanson

Steve is a software developer interested in web development and new technologies. He currently works as a Java consultant at Credera in Dallas, TX.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment