表單驗(yàn)證不了是怎么回事?
<body>
<h1>歡迎登錄我的博客網(wǎng)</h1>
<div id="bg">
??? <form id="login" action="" name="forms">
?? ??? ?<h3>用戶(hù)登錄</h3>
?? ??? ?<div id="inputs">
?????? ??? ?<lable for="username">賬號(hào)<input id="username" type="text" name="Username" autofocus required></lable> <br/>
??????????? <lable for="username">密碼<input id="password" type="password" name="password"? required></lable>
???? ??? ?</div>
?? ???? <div id="actions">
?? ??? ???? <input type="button" id="submit" onClick="#" value="登錄">
?? ??? ???? <input name="提交" type="submit" id="submit" onClick="javascript:location.href='file:///G:/%E5%AD%A6%E4%B9%A0/Untitled-zhuce.html'" value="我要注冊(cè)">
?? ???? </div>
??? </form>
</div>
?? ?
???? <script src="../lib/jquery.js"></script>
?? ?<script src="../lib/jquery.mockjax.js"></script>
?? ?<script src="../lib/jquery.form.js"></script>
?? ?<script src="../dist/jquery.validate.js"></script>
???? <script>
??? ??? ?$(document).ready(function(){
??? ??? ??? ?$("#login").validate({
??? ??? ??? ??? ?rules:{
??? ??? ??? ??? ??? ?username:{
??? ??? ??? ??? ??? ??? ?required:true
??? ??? ??? ??? ??? ??? ?minlength:2
??? ??? ??? ??? ??? ??? ?maxlength:10
??? ??? ??? ??? ??? ?},
??? ??? ??? ??? ??? ?password:{
??? ??? ??? ??? ??? ??? ?required:true
??? ??? ??? ??? ??? ??? ?minlength:2
??? ??? ??? ??? ??? ??? ?maxlength:16
??? ??? ??? ??? ??? ?}
??? ??? ??? ??? ?},
??? ??? ??? ??? ?messages:{
??? ??? ??? ??? ??? ?username:{
??? ??? ??? ??? ??? ??? ?required:"必須填寫(xiě)用戶(hù)名"
??? ??? ??? ??? ??? ??? ?minlength:"用戶(hù)名最小為2"
??? ??? ??? ??? ??? ??? ?maxlength:"用戶(hù)名最大為10"
??? ??? ??? ??? ??? ?},
??? ??? ??? ??? ??? ?password:{
??? ??? ??? ??? ??? ??? ?required:"必須填寫(xiě)密碼"
??? ??? ??? ??? ??? ??? ?minlength:"密碼最小為2"
??? ??? ??? ??? ??? ??? ?maxlength:"密碼最大為16"
??? ??? ??? ??? ??? ?}
??? ??? ??? ??? ?}
??? ??? ??? ?})
??? ??? ?});
???? </script>
</body>
2016-11-07
name="Username" ? 你的name是 大寫(xiě)的 ? ?jquery你寫(xiě)的 小寫(xiě) ?當(dāng)然不能驗(yàn)證了,驗(yàn)證是通過(guò)name屬性來(lái)驗(yàn)證的