Created
March 24, 2016 23:10
-
-
Save fcaldarelli/03b331ae9e8b685353b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If it returns false, validation stops here (and afterValidate event will not be called) | |
$('form').on('beforeValidate', function(event, messages, deferreds) { | |
var extraConditionsSuccess = false; | |
/* | |
* Verify extraConditionsSuccess | |
*/ | |
// if false, afterValidate event will not be called | |
return extraConditionsSuccess; | |
}); | |
$('form').on('afterValidate', function(event, messages, errorAttributes) { | |
// Disable submit button to avoid multiple submits | |
if (errorAttributes.length == 0) { | |
$(this).find('input[type=submit]').attr('disabled', 'disabled'); | |
$(this).find('input[type=submit]').addClass('disabled'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment