Can you make an html button not submit a form

Ask a question+

Whenever I try to build a form with multiple buttons, they all submit the form, but I only want one to, the submit button. Any idea how I can do this?

Can you please add the button code what you are using?

add comment

2 Answers


You need to specify the type attribute like:

<button type="submit"> Submit </button> // will submit the form
<button type="button"> Cancel </button>// simple button, so need to specify the event


<input type="submit" value="Submit" />
<input type="button" value="Cancel" />
Urja 20
add comment

Another option that worked for me was to add onsubmit=”return false;” to the form tag.

<form onsubmit="return false;">

Semantically probably not as good a solution as the above methods of changing the button type, but seems to be an option if you just want a form element the won’t submit.


 <form id="your-form" action="process.php" method="post">
      First name: <input type="text" name="first_name" id="first_name"><br/>
      Last name: <input type="text" name="last_name" id="last_name"><br/>
      Phone number: <input type="text" name="phone_number" id="phone_number"><br/>
      <input type="submit" id="submit-btn">
document.getElementById("submit-btn").addEventListener("click", function(event){

****Or you can Disable button****

 <button type="button" disabled>Click Me!</button>
Gopal Bajpai 210
add comment

Your Answer