为什么即使值相同,验证消息也不会消失?

时间:2017-05-27 09:22:55

标签: javascript jquery

我已经使用jQuery表单验证创建了一个注册表单。验证适用于所有领域。

我通过' equelTo'来比较密码和确认密码。规则,但即使值相同,消息也不会消失。

我创造了一个小提琴来展示我的问题。 click here

$(function() {

  $("form[name='userRegistration']").validate({
    rules: {
      userEmail: {
        required: true,
        email: true
      },
      password: {
        required: true,
        minlength: 6
      },
      rePassword: {
       required: true,
        minlength: 6,
        equalTo: "#password"
      }
    },
    messages: {
      userEmail: "Please enter valid email address.",
      password: {
        required: "Please provide password",
        minlength: "Your password must be at least 6 characters long."
      },
      rePassword: {
        required: "Please provide confirm password",
        minlength: "Confirm password must be at least 6 characters long.",
        equalTo: "Enter Confirm Password Same as Password"
      }
    },
    submitHandler: function(form) {
      form.submit();
    }
  });

1 个答案:

答案 0 :(得分:1)

equalTo: "#password"id="userPassword"

在你的情况下,仔细检查身份证会是我的第一选择......