I'm using the jQuery.validate() to validate my form before it is submitted. Now that I am using Ajax to submit my form, I have a problem.
Note: I am not using the jQuery form plugin. Just so that is clear :)
The jQuery.validate() is fired, but the form submission is also executed.
I don't want the form to be submitted until the validator is ok. Any god suggestions on how I can accomplish this?
UPDATE
I found the answer. I had to use the submitHandler. Now my form is only submitted if all the required fields are corectly populated.
and here's how:
if( jQuery('#my_form').length > 0 ) {
jQuery("#my_form").validate({
rules: {
brand_name: "required",
brand_email: {email: true },
brand_description: "required"
},
submitHandler: function() { processRegistration(jQuery("#my_form").attr("id"), jQuery("#my_form").serialize()); }
});
}