Multiple clicks in Submit causes validation to close longer Jquery Validation Engine

212 views Asked by At

I am using jquery validation engine and I noticed that every time I spam the clicks on the submit button , it takes longer to close and the $("#FORM").validationEngine('hide'); doesn't take effect , I am using Position Absolute Jquery Validation Engine

Here is some of my code

This is to prevent submission upon pressing the submit button:

$('#contactForm').on('submit', function (e) {
        if (!$("#contactForm").validationEngine('validate')) {

        }
        else {
            $('[type="submit"]').prop('disabled', 'disabled');
        }
    });

This is to Hide the Validations upon canceling the request on the modal view window

   $("#btnConfirmEditNo").click(function (e) {
        e.preventDefault();
        $('#editContactForm').validationEngine('hide');
        $('#modalEditWindow').validationEngine('hide');
        editwnd.close();
    });
1

There are 1 answers

0
Kemoy Campbell On

In order to actually prevent the default action/event your first code needs to be like this

    $('#contactForm').on('submit', function (e) {

        e.preventDefault();//prevent the default action from occuring

        if (!$("#contactForm").validationEngine('validate')) {

        }
        else {
            $('[type="submit"]').prop('disabled', 'disabled');
        }
  });