I want to prevent the form from submitting, but execute other form handlers, preventDefault stops all.
here’s an example:
<form id="example">
<input type="text" name="name" />
</form>
<form id="example2">
<input type="text" name="name2" />
</form>
/* generic form handling */
$('form').submit(function(e) {
alert('hello');
});
/*
specific example
i want this handler to prevent the form from submitting normally, but at the same time, i want it to execute the above code with the alert "hello"
*/
$('form#example').submit(function(e) {
e.preventDefault(); // this stops the generic form handling (above) and standard form submission
});
Try returning false (http://api.jquery.com/submit/ states that returning false will stop from submitting):