輕量級的jQuery表單驗證外掛程式 - HAPPY.js

來源:互聯網
上載者:User

功能強大的表單驗證外掛程式很多,以前我們介紹過validation engine,但是如果你希望使用簡單輕量級的表單驗證外掛程式的話,你可以考慮使用HAPPY.js。
主要特性
支援jQuery和Zepto.js
使用簡單,支援日期,數字,電子郵件,最大/最小數和手機號碼等驗證
擁有很多自訂的選項
支援IE6-8,FF3.6,Chrome7和safari5
如何使用
HTML代碼:
<form id="login" action="index.html">
<div class="loginPic">
<input id="loginEmail" class="loginEmail" type="text" placeholder="Your email" name="login">
<input id="loginPassword" class="loginPassword" type="password" placeholder="Your password" name="password">
<div class="logControl">
<input class="buttonM bBlue" type="submit" value="Login" name="submit">
<div class="clear"></div>
</div>
</div>
</form> www.2cto.com
Javascript代碼:
$(function(){
 $('#login').isHappy({
  fields: {
    '#loginEmail': {
   required: true,
   message: 'Please enter your email'
    },
    '#loginPassword': {
   required: true,
   message: 'Please enter password'
    }
  }
 });
});
如果出錯了的話,會添加一個<span>到輸入框前面,並且添加class=“unhappyMessage”,你可以充分自訂。
是不是很簡單,只需要定義表單名稱和對應的輸入框驗證選項,希望大家喜歡這個小巧的jQuery表單驗證類庫!如果你有問題和建議,請給我們留言!
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.