Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Created March 24, 2016 23:10
Show Gist options
  • Save fcaldarelli/03b331ae9e8b685353b7 to your computer and use it in GitHub Desktop.
Save fcaldarelli/03b331ae9e8b685353b7 to your computer and use it in GitHub Desktop.
// 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