是导入的validate.js文件不对吗,为什么怎么弄都没反应,是在官网下的jquery-validation-1.15.0呀?还是代码写错了?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>validate表单验证</title>
<script src="js/jquery-1.12.4.min.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<style>
body
{
font-size:30px;
}
label
{
display:inline-block;
min-width:140px;
}
#demoForm
{
margin:0px auto;
padding:inherit;
height:100px;
border:solid 1px #999;
width:180px;
}
input.error
{
border:solid 2px red;
}
input
{
}
</style>
</head>
<body>
<form id="demoForm">
<fieldset>
<legend>用户登录 </legend>
<p>
<label for="username">用户名</label>
<input type="text" id="username" class="username"/>
</p>
<p>
<label for="password">用户密码</label>
<input type="password" id="password" class="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:{
required:true,
minlength:2,
maxlength:10
},
}
});
});
</script>
</body>
</html>