亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么我跟著老師寫的網頁,只是把js代碼分開一個文件放之后username獲取的時候報錯?

為什么我跟著老師寫的網頁,只是把js代碼分開一個文件放之后username獲取的時候報錯? $("#username").rules() jquery.validate-1.13.1.js:961 Uncaught TypeError: Cannot read property 'getAttribute' of undefined(…)

<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>Document</title>
<link?rel="stylesheet"?type="text/css"?href="style.css"?/>
<script?type="text/javascript"?src="vendor/jquery-1.10.0.js"></script>
<script?src="vendor/jquery.validate-1.13.1.js"></script>
<script?type="text/javascript"?src="script.js"></script>
</head>
<body>
<form?id="demoForm">
<fieldset>
<legend>用戶登陸</legend>
<p?id="info"></p>
<p?id="info2"?style="display:none">輸入錯誤</p>
<p>
<label?for="username">用戶名</label>
<input?type="text"?id="usename"?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>
</body>
</html>
var?validator1;
$(function(){
	validator1?=?$("#demoForm").validate({
		debug:?true,
		rules:?{
			username:?{
				required:?true,
				minlength:2,
				maxlength:10,
			},
			password:{
				required:?true,
				minlength:2,
				maxlength:16,
			},
			"confirm-password":?{
				equalTo:"#password",
			}
		},
		messages:{
			username:{
				required:'請輸入用戶名',
				minlength:'用戶名能小于2個字符',
				maxlength:'用戶名不能大于10個字符',
			},
			password:{
				required:'請輸入密碼',
				minlength:'密碼不能小于2個字符',
				maxlength:'密碼不能超過16個字符',
			},
			"confirm-password":{
				equalTo:'兩次輸入密碼不一致'
			}
		},
	})
})


正在回答

2 回答

id寫錯了

0 回復 有任何疑惑可以回復我~
#1

Bang丶 提問者

非常感謝!
2015-10-26 回復 有任何疑惑可以回復我~

我知道了,id寫錯了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么我跟著老師寫的網頁,只是把js代碼分開一個文件放之后username獲取的時候報錯?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號