0

我正在尝试验证我的一个密码是否等于另一个密码。系统不断标记密码不等于错误。

让我发布我的代码:

<div class="fieldWrapper">
              <label for="password" id="id_password">Password: </label>
              <input id="id_password" type="password" placeholder="Password" name="password" maxlength="128" class="valid">
           </div>

<div class="fieldWrapper">
              <label for="password_verification">Confirm:</label>
              <input id="id_password_verification" type="password" placeholder="Confirm" name="password_verification" maxlength="128">
           </div>

$(document).ready(function()
{
  $("#signup-form").validate({
    rules: {
        password: {
            required: true,
            minlength: 5
        },

        password_verification: {
            required : true,
            equalTo: "#id_password"
        }
    },
    messages: {
        password: {
            required: "Please provide a password",
            minlength: "Your password must be at least 5 characters long"
        },

        password_verification: {
            required: "Please enter your password again",
            equalTo: "Please enter the same password as above"
        },
    },
    submitHandler: function(form) {
        form.submit();
    }
  });
});

有谁知道我在这里哪里出错了?请注意,我的表单具有 id signup-form。

4

1 回答 1

2

id的 HTML 中有重复项:

<label for="password" id="id_password">Password: </label>

从. id_label

于 2012-09-18T03:59:00.940 回答