代碼哪里出問題了嗎 怎么不行啊
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css" media="screen">
??? form{width:300px;}
</style>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>biaodan</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
??? <form id="demoForm">
??? <fieldset> 用戶登陸
??? <p>
??? <label for="username">用戶名:</label>
?? <input type="text" value="" id="username">
??? </p>
??? <p>
??? <label for="password">密碼:</label>
?? <input type="password" value="" id="password">
??? </p>
??? <p><input type="submit" value="登陸"></p>
??? </fieldset>
?? </form>
?? <script src="http://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
<script>
?? $(document).ready(function (){
??? $("#demoForm").validate({
??????? rules:{
????????? username:{
??????????? required:true,
??????????? maxlength:10,
??????????? minlength:2
????????? },
????????? password:{
??????????? required:true,
??????????? maxlength:10,
??????????? minlength:2
????????? }
??????
??????? }
??? });
?? });
</script>
</body>
</html>
2016-10-24
沒引入validate
js代碼中的rules里的屬性名要對應(yīng)表單項(xiàng)里的name,例如你上面的用戶名輸入框代碼可以改成:<input type="text" ?id="username" name="username">,其中name='username'對應(yīng)rules:{username:...}