我有一個註冊表單,在用php編寫的表單中有一些字段要求,我試圖給它添加一個驗證插件,但插件不起作用,我沒有收到任何錯誤。jquery驗證表單不工作
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">
</script>
<script src="scripts/jquery.validate.js"></script>
<script>
$(function(){
$("#regForm").validate({
rules: {
brukernavn: {
required: true,
minlength:3,
maxlength:10
},
passord: {
required: true,
minlength:3,
maxlength:10
},
bekreft_pass: {
required: true,
minlength:3,
maxlength:10
},
E_post: {
required: true,
email: true
},
bekreft_epost {
required: true,
email: true
},
messages: {
}
}
});
$.extend($.validator.messages, {
required: "Obligatorisk felt:"
});
});
</script>
<form id="regForm" method="post" action="">
<label for="brukernavn">Brukernavn</label><br>
<input type='text' id="brukernavn" name="brukernavn"><br>
<label for="passord">Passord</label>
<input type="password" id="passord" name="passord"><br>
<label for="bekreft_pass">Bekreft passord</label>
<input type="password" id="bekreft_pass" name="passord2"><br>
<label for="E_post">E-post</label>
<input type="E-post" id="E_post" name="E-post"><br>
<label for="bekreft_epost">Bekreft e-post</label>
<input type="E-post" id="bekreft_epost" name="E-post2"><br>
<br>
<input type='submit' id"submit" value='Register'>
有誰看到問題出在哪裏?
你還沒有關閉的輸入:
http://jsfiddle.net/samliew/uGsXC/10/
此外,驗證規則名稱必須與NAME字段屬性,而不是ID匹配標籤甚至表格標籤,壞習慣 – dreamweiver 2013-04-18 05:39:52
小提琴,如果有人感興趣:http://jsfiddle.net/samliew/uGsXC/ – 2013-04-18 05:47:58
關閉標籤f或表單似乎沒有與我發佈的代碼,但它在那裏,只是嘗試關閉輸入標籤和問題似乎沒有消失 – Christopher 2013-04-18 05:48:52