Need jQuery.validate to prevent Ajax form submission
I am using jQuery.validate () to validate my form prior to submitting it. Now that I am using Ajax to submit my form, I have a problem.
Note. I am not using the jQuery plugin. It's just so clear :)
JQuery.validate () runs, but form submission is also executed.
I don't want the form to be submitted until the validator has been approved. Any suggestions from God on how I can do this?
UPDATE
I found the answer. I had to use submitHandler. Now my form only submits if all required fields are filled in.
and this is 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()); }
});
}
+2
source to share