title: Intercept a form submit in JavaScript and prevent normal submission
body: <p>There seems to be lots of info on how to submit a form using javascript, but I am looking for a solution to capture when a form has been submitted and intercept it in javascript.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form&gt;
   &lt;input type="text" name="in" value="some data" /&gt;
   &lt;button type="submit"&gt;Go&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When a user presses the submit button, I do <strong>not</strong> want the form to be submitted, but instead I would like a JavaScript function to be called.</p>
  
  <pre><code>function captureForm() {
   // do some stuff with the values in the form
   // stop form from being submitted
  }
  </code></pre>
  
  <p>A quick hack would be to add an onclick function to the button but I do not like this solution... there are many ways to submit a form... e.g. pressing return while on an input, which this does not account for.</p>
  
  <p>Ty</p>