Search code examples
javascriptjquery-validation-engine

Detect actual form submit and show loader


I have a form which has jQuery-Validation-Engine enabled and I want to show a loader once the form is actually getting submitted i.e. when it is without errors. If I am using following code, its getting called even when there are errors in form.

$("#my-form").submit(function(){
  showLoaderGIF here;
});

I would like to know how to detect the actual form submit and not just click on submit button ? Is there any way I can use jQuery-Validation-Engine's 'onSuccess' callback ?

Thanks in advance


Solution

  • Finally, I was able to achieve this using following code

    $("my-form").validationEngine('attach', {    
      onValidationComplete: function(form,status){
        if(status == true){
          showLoader;
          return true;
        }
      }
    });