November 27th 2009

Client Side Validation with xVal for Forms Submitted via Ajax

I had a really hard time figuring out how to use xVal with forms submitted via Ajax and it took a while on Google to try and figure it. All you have to do is set a submitHandler for the form to use. From the jQuery Validate documentation a submitHandler is a:

Callback for handling the actual submit when the form is valid. Gets the form as the only argument. Replaces the default submit. The right place to submit a form via Ajax after it validated.

Code Example: