4 Answers
4

The jQuery Validation plugin is tied to the submit event in jQuery. If you want to trigger this from anywhere else (i.e. any other event handler), you will have to call .submit() manually, which will trigger the validation to occur.

Note that after calling .validate() to set up validation on your form you can store the Validator instance it returns and call the form method on it if you want to perform the validation separately from the submission of the form.

thanks casper.. question for you, what do you mean by "If you want to trigger this from anywhere else (i.e. any other event handler), you will have to call submit manually"? I've tried manually submitting via javascript, as well as a button type of "submit", but it doesn't seem to trigger the validation method. Is there something else I'm missing?
–
ReesMar 2 '10 at 4:46

1

jQuery('#formId').submit(); Thats how you can submit it manually. I posted the answer below.
–
MarkMar 2 '10 at 4:53

I've tried manually submitting via jquery $('#myform').submit(); --and now it validates, but it will immediately submit Even If there are form errors -- which makes me think the submitHandler option isn't being recognized using $('#myform').submit(); --since submitHandler would prevent a form with errors from being submitted. Is there something else I'm missing?
–
ReesMar 2 '10 at 5:15

actually sorry, $('#myform').submit(); is in fact working!! and it doesn't skip over submitHandler.. apparently if you are validating with jquery, you also have to using jquery to submit instead of javascript's document.forms["form"].submit(); Thanks casperone and Mark!
–
ReesMar 2 '10 at 5:20

You can create your own validation and when the form is valid use the above method to submit it. This is the same as clicking a submit button in the form. #formId is the id you've given your form. There are several other ways you can reference the form as well.