<body>
<form id="demoForm">
<fieldset>
<legend>用户登录</legend>
<p>
<label for="username">用户名</label>
<input type="text" id="username" name="username">
</p>
<p>
<label for="password">密码</label>
<input type="password" id="password" name="password">
</p>
<p>
<input type="submit"value="登录">
</p>
</fieldset>
</form>
<script src="js/jquery-1.10.0.min.js"></script>
<script src="js/jquery.validate-1.13.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#demoForm").validate({
rules:{
username:{
required:true,
minlength:2,
maxlength:10
},
password:{
required:true,
minlength:2,
maxlength:16
}
},
messages:{
username:{
required:"必须填写用户名",
rangelength:"用户名应该在2-10位",
},
password:{
required:"必须填写密码",
rangelength:"密码应该在2-16位",
}
}
});
});
</script>
</body>
哎,js名称写错了