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:
Code Snippet
- $("#FormId").data("validator").settings.submitHandler = function(form) {
- $.ajax({
- url: 'your_url',
- type: 'POST',
- data: $(form).serialize(),
- success: function(data) {
- document.forms['FormName'].reset();
- }
- });
- }