Can JQuery.Validate plugin prevent submission of an Ajax form Can JQuery.Validate plugin prevent submission of an Ajax form ajax ajax

Can JQuery.Validate plugin prevent submission of an Ajax form


You need to add a callback function for use with the beforeSubmit event when initializing the ajaxForm():

var options = {        beforeSubmit: function() {            return $('#searchForm').validate().form();        },        target: '#detailsView'    };

Now it knows to check the result of the validation before it will submit the page.


... well it's been a while so my situation has changed a little. Currently I have a submitHandler option passed to the Validate() plugin. In that handler I manually use ajaxSubmit. More a workaround than an answer I guess. Hope that helps.

http://jquery.bassistance.de/validate/demo/ajaxSubmit-intergration-demo.html

var v = jQuery("#form").validate({    submitHandler: function(form) {        jQuery(form).ajaxSubmit({target: "#result"});    }});


$('#contactform').ajaxForm({  success : FormSendResponse,   beforeSubmit:  function(){    return $("#contactform").valid();  }});$("#contactform").validate();   

Above code worked fine for me.