I am trying to clear all error messages as well error highlighting when user click on the clear form button, below are actual requirements
- Validate form using Jquery validation
- When user click on a field error message should be cleared (per field)
- On clicking reset button, every error should be cleared
here is my code
$( document ).ready(function(){
var validator = $("#register_form").validate({
validator.resetForm();
focusCleanup: true,
rules: {
// custom rules
},
messages: {
// custom messages
}
});
For me, first 2 things are working, but when I am trying to clear complete form, I am not able to do this.this is how I am trying to clear it
function clearInputForm(){
alert("");
var validator1 = $( "#register_form" ).validate();
validator1.resetForm();
$("#register_form")[0].reset();
}
But nothing is happening , though with $("#register_form")[0].reset();, form fields are getting clear, but error messages are not getting cleared.
clickevent not getting triggered, issue seems to be withvalidator.resetForm();inside$("#register_form").validatewhich is required to clear per fields error messages