djreed djreed - 7 months ago 26
Javascript Question

Prevent Default on Form Submit jQuery

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

Try this:

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