Prevent Default on Form Submit jQuery

djreed picture djreed · Jun 24, 2011 · Viewed 460.9k times · Source

What's wrong with this?

HTML:

<form action="http://localhost:8888/bevbros/index.php/test" method="post" accept-charset="utf-8" id="cpa-form" class="forms">        
      <input type="text" name="zip" value="Zip code" id="Zip" class="required valid">      
      <input type="submit" name="Next" value="Submit" class="forms" id="1">
  </form>

jQuery:

$("#cpa-form").submit(function(e){
    e.preventDefault();
  });

Answer

Jordan Brown picture Jordan Brown · Jun 24, 2011

Try this:

$("#cpa-form").submit(function(e){
    return false;
});