Hi John,

johnHoysa wrote:
Actually I jumped the gun but hopefully soon I will figure this out.



My understanding is that both ajaxSubmit and validate are registered on the Form submit event. So both events are fired at the same time. Thus when the form's beforeSubmit callback fires, the validation already executed. At least that is what I've observed :)

To get both working together I did the following (perhaps you can enhance it to fit your needs):


  // Define an indicator for validation success/fail status
  var valid = false;

  // Setup the validation options
  var validationOptions {

      // this callback is invoked on successful validation
      submitHandler: function(form) {
          // we set valid indicator to true
          valid = true;
      },

      // this callback is invoked on failed validation
      invalidHandler: function(form, validator) {
          // we set valid indicator to false
          valid = false;

      } // add further validation options here
  }

  var formOptions {
    beforeSubmit:  preSubmit,
    // define more form options here
  }

  // The Form preSubmit handler
  function preSubmit(formData, jqForm, options) {
    // If form validation failed we return false to stop Form submit
    if (!valid) {
        return false;
    }
  }

// Define
jQuery("#form").validate(validationOptions);
jQuery('#form').ajaxForm(formOptions);


Hope this is helpful.

kind regards

bob

Reply via email to