我正在使用jQuery Validate Plugin:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
简单演示:
<input type="text" name="email" class="required email" /> <input type="text" name="email_confirm" class="required email" />
如何检查两个输入中的值是否与jQuery或jQuery Validate Plugin相同.
我只是尝试了相同,它的工作原理:
rules: { email: 'required',email2: {equalTo: '.email'}
解决方法
通过查看
http://jquery.bassistance.de/validate/demo/的演示页面,您可以使用“equalTo”验证两个应该相等的字段:
$("#signupForm").validate({ rules: { ...snip... password: { required: true,minlength: 5 },confirm_password: { required: true,minlength: 5,equalTo: "#password" },...snip... },messages: { ...snip... password: { required: "Please provide a password",minlength: "Your password must be at least 5 characters long" },confirm_password: { required: "Please provide a password",minlength: "Your password must be at least 5 characters long",equalTo: "Please enter the same password as above" },...snip... } });
要使用类方法,只需要找到语法.我找不到equalTo属性,但它可能是这样的:
class="required email equalTo['email']"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。