[英]Password confirm validation fails
HTML code: HTML代码:
<div id="form_pwd">
<form method="POST" action="google.com" id="pwdChange">
<table>
<tr>
<td width="175px"><label for="newPwd">Enter your password</label></td>
<td><input type="password" name="newPwd" id="newPwd" size="35"/></td>
</tr>
<tr>
<td><label for="newPwd_">Re-enter your password</label></td>
<td><input type="password" name="newPwd_" id="newPwd_" size="35"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save Password" /></td>
</tr>
</table>
</form>
</div>
jQuery code: jQuery代码:
$(document).ready(function()
{
$("#form_pwd").validate(
{
rules:
{
newPwd: "required",
newPwd_:
{
equalTo: "#newPwd"
}
}
}
);
}
);
I use the above source to validate my input passwords but there is nothing being shown next to the text boxes, would someone please have a look and help me spot it ? 我使用上面的来源来验证我的输入密码,但是文本框旁边没有显示任何内容,请您看一下并帮助我找到它吗? i already include
我已经包括
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
</script>
at the top of the file. 在文件的顶部。 :(
:(
[ Update ]Ok, the demo is here http://jsfiddle.net/Z9JmB/2/ [ 更新 ]好的,演示在这里http://jsfiddle.net/Z9JmB/2/
I hope someone could help me out with this tiny problem. 我希望有人可以帮助我解决这个小问题。 Thank you sooo much .
太谢谢你了。
This works fine, but you're targeting the div outside of the form. 效果很好,但是您将div定位到了表单之外。 You need to change the target element from:
您需要从以下位置更改目标元素:
$("#form_pwd")
to: 至:
$("#pwdChange")
This will target your form. 这将针对您的表单。
Also, in your JS fiddle, you need to include your validation js file. 另外,在JS小提琴中,您需要包括验证js文件。 I updated the jsfiddle to include the validation plugin your using, it all works 100% correctl, please have a look:
我更新了jsfiddle以包括您使用的验证插件,所有这些都可以100%正确地运行,请看一下:
This looks fine. 看起来不错。 Make sure your password input has
id="newPwd"
or post more code. 确保您的密码输入具有
id="newPwd"
或发布更多代码。 Maybe setup a jsfiddle.net 也许设置一个jsfiddle.net
Also see manual http://docs.jquery.com/Plugins/Validation/Methods/equalTo#other 另请参见手册http://docs.jquery.com/Plugins/Validation/Methods/equalTo#other
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.