jQuery-Form-Validator
jQuery-Form-Validator copied to clipboard
Enhancement request: Pass through the event, which triggered from submission/validation
First of all, thank you for writing this wonderful and flexible plugin.
I have one suggestion/enhancement request. I think one issue I ran into with this validating forms with multiple submit buttons. I had to do some workarounds to figure out which one of the submit buttons fired the event submission. I think passing through the event, which triggered the form submission/validation to the callback functions would solve the problem.
Ex:
$.validate({
form : '#registration-form',
modules : 'security',
onError : function($form, event) {
console.log('this element started the event chain', event.target);
alert('Validation of form '+$form.attr('id')+' failed!');
},
onSuccess : function($form, event) {
console.log('this element started the event chain', event.target);
alert('The form '+$form.attr('id')+' is valid!');
return false; // Will stop the submission of the form
},
onValidate : function($form, event) {
console.log('this element started the event chain', event.target);
return {
element : $('#some-input'),
message : 'This input has an invalid value for some reason'
}
},
onElementValidate : function(valid, $el, $form, errorMess) {
console.log('Input ' +$el.attr('name')+ ' is ' + ( valid ? 'VALID':'NOT VALID') );
}
});
Thank you for your consideration.