<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
<style>
p {
color: red;
}
</style>
<script src="vendor/jquery-1.10.0.js"></script>
<script src="vendor/jquery.validate-1.13.1.js"></script>
</head>
<body>
<form id="demoForm">
<fieldset>
<legend>用户登录</legend>
<p id="info"></p>
<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>
<label for="confirm-password">确认密码</label>
<input type="password" id="confirm-password" name="confirm-password"/>
</p>
<p>
<input type="submit" value="登录"/>
</p>
</fieldset>
</form>
<script>
$(document).ready(function(){
$('#demoForm').validate({
rules:{
username:{
required:true,
minlength:2,
maxlength:10
},
password:{
requierd:true,
minlength:2,
maxlength:16
}
}
});
});
</script>
</body>
</html>
代码没有问题,是否已在工程项目中加入vendor文件夹,vendor文件夹应包含jquery-1.10.0.js,jquery.validate-1.13.1.js
这两个js文件,以便加载jQuery validate 插件