title: Stop form submit with native javascript
body: <p>I need to select a form via native javascript (not jQuery) and prevent the form submission (preventDefault).</p>
  
  <p>The trick is that the form does not have a name or id, and cannot be assigned one.</p>
  
  <p>My HTML:</p>
  
  <pre><code>&lt;div id="search"&gt;
      &lt;form method="get"&gt;
          &lt;input type="text" name="post"/&gt;
          &lt;input type="submit" value="Post"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So far, I have tried to use <code>document.forms[0]</code> and <code>document.getElementsByTagName("form")[0]</code> to select the form, but the value returned is undefined.</p>
  
  <p>Another possible solution is to overload the functionality of the submit button, but I did not have success with that either.</p>