<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" content="text/html">
<script src = "D:\mycode\jquery-3.2.1.js"></script>
<script src = "D:\mycode\jquery.validate-1.13.1.js"></script>
<link rel="stylesheet" type="text/css" href="css/validform.css">
<title>validation Demo</title>
</head>
<body>
<form id = "form1">
<fieldset>
<legend>用户登录</legend>
<p>
<LABEL for = "username">用户名</LABEL>
<input type="text" name="username" id="username">
</p>
<p>
<LABEL for = "password">密码</LABEL>
<input type="text" name="password" id="password">
</p>
<p>
<input type="submit" value="登录">
</p>
</fieldset>
</form>
<script type = "text/javascript">
$(document).ready(function(){
alter("sadd");
$("#form1").validate({
rules:{
username:{
required:true,
minilength:2,
maxlength:10
},
password:{
required:true,
minilength:2,
maxlength:10
}
}
});
});
</script>
</body>
</html>
找到问题了,alter那句错了,删了就行了。
<meta charset="utf-8" content="text/html">
<script src = "D:\mycode\jquery-3.2.1.js"></script>
<script src = "D:\mycode\jquery.validate-1.13.1.js"></script>
<link rel="stylesheet" type="text/css" href="css/validform.css">
这几行代码有错误