標籤:
今天給大家分享一款基於jQuery的註冊表單,這款註冊表單的特點是確認提交註冊資訊時,表單會自動驗證所填寫的資訊,如果資訊填寫有誤,即會在相應的欄位內以Tooltip提示框的形式顯示錯誤資訊。這款jQuery表單實現非常簡單,使用起來相對比較輕巧。
線上預覽 源碼下載
這款外掛程式js要引用jquery.js庫,還有一個easyform.js 庫。
html代碼部分如下:
<div class="form-div"> <form id="reg-form" action="" method="post"> <table> <tr> <td> 使用者名稱 </td> <td> <input name="uid" type="text" id="uid" easyform="length:4-16;char-normal;real-time;" message="使用者名稱必須為4—16位的英文字母或數字" easytip="disappear:lost-focus;theme:blue;" ajax-message="使用者名稱已存在!"> </td> </tr> <tr> <td> 密碼 </td> <td> <input name="psw1" type="password" id="psw1" easyform="length:6-16;" message="密碼必須為6—16位" easytip="disappear:lost-focus;theme:blue;"> </td> </tr> <tr> <td> 確認密碼 </td> <td> <input name="psw2" type="password" id="psw2" easyform="length:6-16;equal:#psw1;" message="兩次密碼輸入要一致" easytip="disappear:lost-focus;theme:blue;"> </td> </tr> <tr> <td> email </td> <td> <input name="email" type="text" id="email" easyform="email;real-time;" message="Email格式要正確" easytip="disappear:lost-focus;theme:blue;" ajax-message="這個Email地址已經被註冊過,請換一個吧!"> </td> </tr> <tr> <td> 暱稱 </td> <td> <input name="nickname" type="text" id="nickname" easyform="length:2-16" message="暱稱必須為2—16位" easytip="disappear:lost-focus;theme:blue;"> </td> </tr> </table> <div class="buttons"> <input value="注 冊" type="submit" style="margin-right: 20px; margin-top: 20px;"> <input value="我有帳號,我要登入" type="button" style="margin-right: 45px; margin-top: 20px;"> </div> <br class="clear"> </form> </div> <script type="text/javascript"> $(document).ready(function () { $(‘#reg-form‘).easyform(); }); </script>
via:http://www.w2bc.com/Article/13972
一款基於jQuery的帶Tooltip表單驗證的註冊表單