Jquery form ajaxsubmit, stop of server side validation fails

Jquery form ajaxsubmit, stop of server side validation fails

Hi all,

I am making a call to a php file which right at this minute has no validation, all validation is been done by the jquery form plugin. I post to the thanks file but if the validation (xss prevention soon to be implemented) in the thanks fails I want to stop the processing of the form i.e. stop the return of success.

How do I do this, any insight appreciated.

$("#myform").validate({
      submitHandler: function(myform) {
         jQuery(myform).ajaxSubmit({
            type: "POST",
               url: "thanks.php",
            success: function() {
               $('#contact_form').html("<div id='message'></div>");
               $('#message').html("<h2>Contact Form Submitted!</h2>") 
              .append("<p>We will be in touch soon.</p>") 
              .hide() 
              .fadeIn(1500, function() { 
                 $('#message').append("<img id='checkmark' src='/images/check.png' />"); 
              });
            }
         });
      }