Friday, 19 October 2012

AJAX Form Submit and jQuery Validation

Submitting a form using jQuery AJAX should be pretty straight forward by using click() on the submit button, then some $.ajax() call. Integrating jQuery validation to it is a little bit tricky. Normal form submit without AJAX seems to call valid() automatically when the button is clicked, but with AJAX, it did not seem to work for me. I had to call this manually for the validations to work by using:
if ($.("#myForm").valid()) {
    // do form submission AJAX call here

blog comments powered by Disqus