开发者

Is there an easy way to match 3 fields with jquery validate

开发者 https://www.devze.com 2023-03-12 06:51 出处:网络
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 t

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"
    }
  }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消