欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery表單驗(yàn)證插件validation使用方法詳解

 更新時(shí)間:2017年01月20日 09:58:43   作者:BaldWinf  
這篇文章主要為大家詳細(xì)介紹了jquery表單驗(yàn)證插件validation使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、如何使用

引入js文件

<script src="jquery.js"></script>
<script src="jquery.validate-1.13.1.js"></script>

編寫(xiě)html頁(yè)面,這里僅以用戶(hù)名、密碼為例

<body>
 <form id="demoForm">
  <fieldset>
   <legend>用戶(hù)登錄</legend>
   <p>
    <label for="username">用戶(hù)名</label>
    <input type="text" id="username" name="username">
   </p>
   <p>
    <label for="password">密碼</label>
    <input type="text" id="password" name="password">
   </p>
  </fieldset>
 </form>
</body>

編寫(xiě)script腳

$(document).ready(function(){
 $("#demoForm").validate({
  rules:{
   username:{
    required:true,// 是否必填
    minlength:2, // 最小長(zhǎng)度
    maxlength:10 // 最大長(zhǎng)度
   },
   password:{
    required:true,
    minlength:2,
    maxlength:16
   }
  }
 });
});

二、測(cè)試

如果大家還想深入學(xué)習(xí),可以點(diǎn)擊兩個(gè)精彩的專(zhuān)題:jquery表單驗(yàn)證大全 JavaScript表單驗(yàn)證大全

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論