<2009年10月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          統(tǒng)計(jì)

          • 隨筆 - 16
          • 文章 - 0
          • 評(píng)論 - 6
          • 引用 - 0

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          jquery validation
           1<%@page contentType="text/html; charset=GBK"%>
           2<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
           3<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
           4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
           5<html xmlns="http://www.w3.org/1999/xhtml" lang="GBK" xml:lang="GBK">
           6<head>
           7<meta http-equiv="Pragma" content="no-cache" />
           8<meta http-equiv="Cache-Control" content="no-cache" />
           9<meta http-equiv="Expires" content="0" />
          10<link type="text/css" title="www" rel="stylesheet" media="all" href="<c:url value="/theme/1/control/control.css"/>" />
          11<title>jQuery之驗(yàn)證插件</title>
          12    <style type='text/css'>
          13           *{font-family:Verdana;font-size:96%;}
          14           label.error{float:none;color:red;padding-left:.5em;vertical-align:top;}
          15           p{clear:both;}
          16           .submit{margin-left:12em;}
          17           em{font-weight:bold;vertical-align:top;}
          18       
          </style>
          19<script type='text/javascript'  src='<c:url value="/js/jquery-1.3.2.js"/>'></script>
          20<script type='text/javascript' src='<c:url value="/js/jquery.validate.js"/>'></script>
          21<script type='text/javascript'>
          22           $(document).ready(function(){
          23              $('#commentForm').validate({
          24                  rules:{
          25                     username:{
          26                         required:true,
          27                         minlength:1,
          28                         formula:"7+9"
          29                     }
          ,
          30                     email:{
          31                         required:true,
          32                         email:true
          33                     }
          ,
          34                     url:"url",
          35                     comment:"required",
          36                     coco:{formula:"7+9"},
          37                     valcode:{formula:"7+9"}
          38                  }
          ,
          39                  messages: {   
          40                         //為name為email的控件的required()和email()驗(yàn)證方法設(shè)置驗(yàn)證失敗的消息內(nèi)容   
          41                         email: {required:"需要輸入電子郵箱", email:"電子郵箱格式不正確"}   
          42                     }
            
          43              }
          )
          44           }
          );
          45
          46           $.validator.addMethod(   
          47                    "formula",                       //驗(yàn)證方法的名稱   
          48                    function(value,element,param){   //驗(yàn)證規(guī)則   
          49                       return value==eval(param);    
          50                       }
          ,   
          51                      '請(qǐng)輸入正確的結(jié)果'                //提示驗(yàn)證信息   
          52            );   
          53       
          </script>
          54</head>
          55
          56<body>
          57       <form class='cmxform' id='commentForm' method='post' action='#'>
          58           <fieldset>
          59              <legend>一個(gè)簡(jiǎn)單的帶有提示的評(píng)論例子</legend>
          60              <p>
          61                  <label for='cusername'>姓名</label><em>*</em>
          62                  <input id='cusername' name='username' size='25' />
          63              </p>
          64              <p>
          65                  <label for='cemail'>電子郵件</label><em>*</em>
          66                  <input id='cemail' name='email' size='25' />
          67              </p>
          68              <p>
          69                  <label for='curl'>網(wǎng)址</label><em>*</em>
          70                  <input id='curl' name='url' size='25' value=''/>
          71              </p>
          72              <p>
          73                  <label for='cverify'>7+9=</label><em>*</em>
          74                  <input id='cverify' name='coco' size='25' value=''/>
          75              </p>
          76<p>  
          77    <label for='cvalcode'>驗(yàn)證碼</label>  
          78    <input id='cvalcode' name='valcode' size='25' value=''/>=7+9   
          79</p> 
          80              <p>
          81                  <label for='ccomment'>你的評(píng)論</label><em>*</em>
          82                  <textarea id='ccomment' name='comment' cols='25'></textarea>
          83              </p>
          84              <p>
          85                  <input class='submit' type='submit' value='提交'>
          86              </p>
          87           </fieldset>
          88       </form>
          89    </body>
          90</html>
          91
          92
          93
          94

          posted on 2009-10-15 13:37 R99 閱讀(407) 評(píng)論(0)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 理塘县| 萝北县| 峨眉山市| 鲁甸县| 望都县| 电白县| 平顺县| 景洪市| 万全县| 明水县| 聊城市| 鹤山市| 离岛区| 武安市| 宜阳县| 广南县| 麻栗坡县| 乌拉特前旗| 肃北| 突泉县| 双江| 罗江县| 廉江市| 武夷山市| 建平县| 伊吾县| 甘德县| 济源市| 三门县| 涞源县| 象州县| 嵊泗县| 油尖旺区| 马关县| 收藏| 兴宁市| 和静县| 辽阳县| 汕尾市| 阳朔县| 修文县|