jquery validate是一個表單較難的jquery插件,在github上的地址是:https://github.com/jzaefferer/jquery-validation,應(yīng)用比較簡單,當然也可以從jquery的官網(wǎng)獲取得到http://archive.plugins.jquery.com/project/validate。


          使用的時候引用jquery的庫和validate的庫就可以了,使用方面看下面的例子。

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          35
          36
          37
          38
          39
          40
          41
          42
          43
          44
          45
          46
          47
          48
          49
          50
          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
          <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
              <title>jquery validate 插件實例01</title>
              <meta name="author" content="Administrator" />
              <link rel="stylesheet" type="text/css" href="js/css/screen.css" />
              <script type="text/javascript" src="js/jquery-1.9.0.js"></script>
              <script type="text/javascript" src="js/jquery.validate.js"></script>
              <script type="text/javascript">
              $(function(){
                      $("#myform").validate({
                      rules:{
                  username:"required",
                  address:{
                          required:true,
                      minlength:3
                  },
                  age:"digits",
                  pwd:"required",
                  cpwd:{
                      equalTo:"#pwd"
                  }
                  },
                  messages:{
                  username:"用戶名必須輸入",
                  address:{
                          required:"用戶地址必須輸入",
                      minlength:"地址不能小于3位"
                  },
                  age:"年齡必須是整數(shù)",
                  pwd:"密碼必須輸入",
                  cpwd:"兩次密碼不一致"
                  }
              });
              });
              </script>
          </head>
          <body>
              <form id="myform" action="#">
              Username:<input type="text" id="username" name="username"/><br/>
              Address:<input type="text" id="address" name="address"/><br/>
              Age:<input type="text" id="age" name="age"/><br/>
              password:<input type="text" id="pwd" name="pwd"/><br/>
              confirm password:<input type="text" id="cpwd" name="cpwd"/><br/>
              <input type="submit" />
              </form>
          </body>
          </html>


          本文鏈接:jquery validate 插件實例教程,由領(lǐng)悟書生原創(chuàng)

          轉(zhuǎn)載請注明出處【http://www.656463.com/article/358】


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 临汾市| 鄂伦春自治旗| 通化县| 靖江市| 莱州市| 保德县| 敖汉旗| 遵义市| 新乐市| 福州市| 库伦旗| 阿城市| 衡水市| 弋阳县| 武冈市| 剑阁县| 定州市| 漠河县| 肃北| 大庆市| 克东县| 西和县| 儋州市| 博兴县| 明光市| 永靖县| 启东市| 三原县| 浦北县| 榆社县| 临澧县| 顺义区| 崇阳县| 潞西市| 睢宁县| 南召县| 八宿县| 麻江县| 湘西| 叶城县| 紫云|