Is there an easy way to match 3 fields with jquery validate
I need to compare 3 fi开发者_运维知识库elds with jquery validate to ensure they match. If they don't match, I need all three fields to be hightlighted in error. Is there a relatively simple way to do this?
Use the equalTo validation method to require that one element's value be the same as that of another element. So, you'll need two of these, one pointing to each of the other two fields. However, I think you would only need to put them on one of the three fields.
Sample, taken from the plugin's documentation:
$("#myform").validate({
rules: {
password: "required",
password_again: {
equalTo: "#password"
}
}
});
精彩评论