I want to call a jquery function to manually remove errors from a single field and reset the error markup. Is there a function that does this that would be similar to the reset
This functionality is possible via focusCleanup: true
option and triggering focusin
event on desired element. But it is not always desirable to trigger this event. So apparently, you can use plugin’s internal code which is running on focusin
and invoke it externally like so:
/*get your element and containing validated form*/
var $that = $('#desired_elemenet');
var $form = $that.closest('form');
/*get validator object for the form*/
var validator = $form.validate();
/*use internal code of a plugin to clear the field*/
if (validator.settings.unhighlight) {
validator.settings.unhighlight.call( validator, $that[0], validator.settings.errorClass, validator.settings.validClass );
}
validator.hideThese( validator.errorsFor( $that[0] ) );