You should not be calling submit() first. You only call it after everything is validated. This can be as easy as a if-statement. Here's a simple example. Modify it to work with your scenrio.
$(function() { $('#testForm').bind('submit', function() { $(this).validate(validation_options); var valid = $(this).valid(); if (valid) { // do your ajax } }); }); var validation_options = { // set your options here }; On Oct 2, 9:13 am, coachz <bringmewa...@gmail.com> wrote: > when i run "this.submit();" i submit my ajax request, so how can i > get the validate to fire on invalidHandler and submitHandler so I will > only run this.submit(); when it passes validation ? Currently the > validator does not validate the form at all on submit, I need it to > cancel the submit if there are validation issues and submit if there > are none. > > function submitForm(form) { > > this.submit(); > > $("#frmAddTask").validate({ > errorPlacement: function(error, element) { > error.insertAfter > (element); }, > invalidHandler: function(form, validator) { > alert("validation > failed"); }, > submitHandler: function(form, validator) { > alert("validation > passed"); }, > rules: { title: { required: true, minlength: 5 } > } > }); > > } > > // Build Add a New Task pop up dialog > // Instantiate the Add a New Task pop up dialog > YAHOO.util.Dom.removeClass('dlgAddTask', 'hideForm'); > YAHOO.techdocs.dlgAddTask = new YAHOO.widget.Dialog("dlgAddTask", > { width : "50em", height: "32em", fixedcenter : true, visible : > false, constraintoviewport : true, close: false, > buttons : [ { text:"Submit", handler:submitForm, > isDefault:true }, > { text:"Cancel", handler:function() > {this.cancel();} } ] > });