表單問題,是個糾結的問題,我覺得這個是程式開發人員要去處理的東西,但是有時候程式又要前端去處理,那要看你的後台夥伴怎麼樣了?苦逼的前端哇,不過還是自己了解一點還是比較好,你搞我也可以搞,你不搞我還可以搞,哈哈 。如果對你有用歡迎留言,共同探討,共同進步,廢話不說,貼代碼(為了童鞋們方便,本代碼複製即可用,無需分塊拼湊): 複製程式碼 程式碼如下: 表單驗證表單驗證的完整應用 <BR>.leftside{width:100px; text-align:right;float:left;} <BR>label.error{color: #ea5200; margin-left:4px; padding:0px 20px; background:url(http://jt.875.cn/icon/unchecked.gif) no-repeat 2px 0 } <BR>label.right{margin-left :4px; padding-left:20px; background:url(http://jt.875.cn/icon/checked.gif) no-repeat 2px 0} <BR> <BR>$(function(){ <BR>$( "#regForm" ).validate ({ <BR>rules: { <BR>// 註冊使用者名稱<BR>username: { <BR>required: true, <BR>minlength: 5, <BR>maxlength: 12 <BR>}, <BR>, <BR> // email <BR>email: { <BR>required: true, <BR>email: true <BR>}, <BR>// 密碼<BR>password: { <BR>required: true, <BR> : 6, <BR>maxlength: 18 <BR>}, <BR>// 確認密碼<BR>confirm_password: { <BR>equalTo:"#password" <BR>}, <BR>// 檢定驗證碼<BR>captcha: { <BR>required: true, <BR>remote: "checkCaptcha.php" <BR>} <BR>}, <BR>messages: { <BR>// 註冊用戶名<BR>username: { <BR>required: "此項不能為空", <BR>minlength: "不能少於5個字元", <BR>maxlength: "不能多於12個字" <BR>}, <BR>/ / email <BR>email: { <BR>required: "此項目不能為空", <BR>email: "email格式不正確" <BR>}, <BR>// 密碼<BR>password: { <BR>required: "此項不能為空", <BR>minlength: "不能少於6個字元", <BR>maxlength: "不能多於18個字元" <BR>}, <BR>// 確認密碼<BR>confirm_password: "兩次輸入密碼不一致", <BR>// 檢驗驗證碼<BR>captcha: { <BR>required: "請輸入驗證碼", <BR>remote: "驗證碼輸入錯誤" <BR>} <BR>} <BR>}); <BR>}); <BR> 姓名: 密碼: 確認密碼: EMAIL: 效果圖如下