title: How can I make a second button in my form not run the submit code after it's pressed?
body: <p>I have a form, with a submit button:</p>
  
  <pre><code>&lt;% form_for(@personalentry) do |f| %&gt;
      &lt;%= f.submit 'Create' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>HTML Output</p>
  
  <pre><code>&lt;form action="/personalentries" class="new_personalentry" id="new_personalentry" method="post"&gt;
      &lt;input id="personalentry_submit" name="commit" type="submit" value="Create" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to add a second button, to do some other code not related to form submitting. So I did this:</p>
  
  <pre><code>&lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function addEndDateCalendar(){
              alert("test");
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="/personalentries" class="new_personalentry" id="new_personalentry" method="post"&gt;
          &lt;button name="addEndDateButton" onClick="addEndDateCalendar()"&gt;End date?&lt;/button&gt;
          &lt;input id="personalentry_submit" name="commit" type="submit" value="Create" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>When I click the button, the alert comes up, but then it runs the submit code. How can I make this second button not run the submit code after it runs its own code? Thanks for reading.</p>