<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
form{
border:1px solid gainsboro;
}
</style>
</head>
<body>
<form id="demo">
用户名:<input type="text" name="userName"/><br>
密 码:<input type="password" name="passWord"/>
<input type="submit" value="登录"/>
</form>
<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
<script type="text/javascript" src="js/jquery.validate.js" ></script>
<script>
$(document).ready(function(){
$("#demo").validate({
rules:{
userName:{
required:true,
mixlength:2,
maxlength:10,
remote:"remote.json"
},
passWord:{
required:true,
mixlength:2,
maxlength:16
}
},
messages:{
userName:{
required:'必填',
mixlength:'最小长度为2',
maxlength:'最大长度为10'
},
passWord:{
required:'必填',
mixlength:'最小长度为2',
maxlength:'最大长度为16'
}
}
});
});
</script>
</body>
</html>
自己创建了一个json文件,和index.html同层。json内容false
谷歌浏览器运行看不到json
mixlength 这个词 你写错了 应该是minlength 四个地方都错了 我用你的测试了 改过后就好了