<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>表單驗證</title> <style type="text/css"> body{margin: 0;padding: 0} form{margin: 50px 100px;height: auto;} legend{font-size: 24px;font-weight: bold} p label{font-size: 18px;font-family: 微軟雅黑;display: inline-block;width: 80px;} p input{width: 140px;height: 20px;line-height: 20px;font-size: 16px} #sub{width: 80px;height: 30px;} form p:last-child{margin-left: 80px;margin-bottom: 10px} </style> <script src="jquery.validate-1.13.1.js"></script> <script src="jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(function(){ validator = $("#demoForm").validate({ 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: "兩次輸入密碼不一致"? ? ? ? ? ? ? ? }? ? ? ? ? ? } }) }) </script></head><body> <form id="demoForm"> <fieldset> <legend>會員登錄</legend> <p id="info"></p> <p> <label for="username">用戶名:</label> <input type="text" name="username" id="user"> </p> <p> <label for="password">密 碼:</label> <input type="password" name="password" id="psd"> </p> <p> <label for="confirm-password">確認密碼:</label> <input type="password" name="confirm-password" id="conf"> </p> <p> <input type="submit" ?id="sub" name="submit" value="提交"> </p> </fieldset> </form> </body></html>
急急急?。?!關于jQuery插件validate的問題,下面一段代碼,當輸入不正確的信息為什么沒有提示?
IT菜_鳥
2016-04-14 20:51:37