首页 > 代码库 > Jquery validate 验证

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 =http://www.mamicode.com/= "1")>

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>}});


Jquery validate 验证