// 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');
}
});