I am using jquery and validate to validate my form. Instead of adding an element to the missing field I am adding a border to the element using this option errorPlacement
$("#signup-form").validate({
submitHandler: function(form) {
form.submit();
},
errorPlacement: function(error, element) {
element.css("border", "solid 1px red");
}
});
the one thing i can not seem to figure out is how to clear it when valid?
So I started with the above code. Then tried and i am confused with the results.
If I do not have the success: option when a field fails it adds the class successfully. But as soon as I add the success option all the required fields are getting that class, and if I inspect the element I see <input class="required invalid valid"> so I am doing something incorrectly.
$("#signup-form").validate({
submitHandler: function(form) {
// do other stuff for a valid form
//form.submit();
},
errorPlacement: function(error, element) {
element.addClass("invalid");
},
success: function(error) {
// change CSS on your element(s) back to normal
},
debug:true
});