I use jquery and validate to validate my form. Instead of adding an element to the missing field, I add a border to the element using this errorPlacement option
$("#signup-form").validate({
submitHandler: function(form) {
form.submit();
},
errorPlacement: function(error, element) {
element.css("border", "solid 1px red");
}
});
The only thing I can’t understand is to clear it when it is valid?
So, I started with the above code. Then I tried, and I am confused by the results. If I do not have the option success:if the field is unsuccessful, it successfully adds the class. But as soon as I add a parameter success, all the required fields get this class, and if I check the element, I see <input class="required invalid valid">, so I'm doing something wrong.
$("#signup-form").validate({
submitHandler: function(form) {
},
errorPlacement: function(error, element) {
element.addClass("invalid");
},
success: function(error) {
},
debug:true
});
randy source
share