我正在尝试验证我的表单,由于某种原因,即使我没有在密码字段的字段中输入任何值,它也总是验证为真。如果我将控件更改为文本,如果我没有在文本框中输入任何内容,则验证工作。下面是我的代码。我无法弄清楚我在这里做错了什么。
<form id="frmChangePassword" action="http://localhost/PatientAccount" method="post">
<div class="row"><input type="password" id="txtPWD" name="txtPWD" placeholder="" style="" class="text focus" value=""></div>
<div class="row"><input type="password" id="txtReEnterPWD" name="txtReEnterPWD" placeholder="" style="" class="text" value=""></div>
<div class="row"><input type="Button" ID="btnChangePassword" Name="btnChangePassword" STYLE="" Class="btn-submit" VALUE="Change Password" onClick="javascript:ValidateResetPassword();"></div>
</form>
<script>
function ValidateResetPassword() {
$("#frmChangePassword").validate({
rules: {
"txtPWD": { required:true },
"txtReEnterPWD": { required:true }
},
messages: {
"txtPWD": { required: "Please enter Password" },
"txtReEnterPWD": {required: "Please re-enter password" }
}
});
if ($("#frmChangePassword").valid()) {
hashPassword();
}
}
</script>