Jquery validate 验证
1 必填和远程校验
$("#inputForm").validate({ rules: { "username": "required", "loginid": { remote: { type: "post", url: "${ctx}/user/isUniCode.do", data: { code: function() { return $("#loginid").val(); } }, dataType: "html", dataFilter: function(data, type) { if (data == "1") return true; else return false; } } } }, messages: { username: "请填写名称", loginid: { remote: "角色编号已存在" } } });
2 密码验证
$("#inputForm").validate({ <span style="white-space:pre"> </span>rules: { <span style="white-space:pre"> </span>pwd:{ <span style="white-space:pre"> </span>required: true, <span style="white-space:pre"> </span>minlength: 6 //自带判断字符最小长度 <span style="white-space:pre"> </span>}, <span style="white-space:pre"> </span>pwdRepeat: { <span style="white-space:pre"> </span> required: true, <span style="white-space:pre"> </span> minlength: 6, <span style="white-space:pre"> </span> equalTo: "#pwd" <span style="white-space:pre"> </span>} <span style="white-space:pre"> </span>}, <span style="white-space:pre"> </span>messages: {<span style="white-space:pre"> </span> <span style="white-space:pre"> </span> <span style="white-space:pre"> </span>pwd:{ <span style="white-space:pre"> </span>required: '请输入密码', <span style="white-space:pre"> </span>minlength: "确认密码不能小于6个字符" <span style="white-space:pre"> </span>}, <span style="white-space:pre"> </span>pwdRepeat: { <span style="white-space:pre"> </span>required: "请输入确认密码", <span style="white-space:pre"> </span>minlength: "确认密码不能小于6个字符", <span style="white-space:pre"> </span>equalTo: "两次输入密码不一致" <span style="white-space:pre"> </span> } <span style="white-space:pre"> </span>} });
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。