title: How do I stop a form from submitting?
body: <p>How to I stop a form from submitting? 
  I have some validation on my form, and if the the input isn't correct, then the form should't submit...
  In my HTML i have this when clicking submit:</p>
  
  <pre><code>&lt;a href="#" onclick="setTimeout(function(){document.getElementById('form_4').submit()}, 1000);" style="position:static" class="btn-more"&gt;Vælg&lt;/a&gt;
  </code></pre>
  
  <p>And the my script looks like this: </p>
  
  <pre><code>$("#form_4 a.btn-more").click(function (e) {
  
      //Validate required fields
      for (i = 0; i &lt; required.length; i++) {
          var input = $('#' + required[i]);
  
          if ((input.val() == "") || (input.val() == emptyerror)) {
              input.addClass("needsfilled");
              input.val(emptyerror);
              errornotice.fadeIn(750);
              e.stopPropagation();
              return false;
          } else {
              input.removeClass("needsfilled");
          }
      }
      //if any inputs on the page have the class 'needsfilled' the form will not submit
      if ($(":input").hasClass("needsfilled")) {
          return false;
      } else {
          errornotice.hide();
          return true;
      }
  });
  </code></pre>