請選擇汽車類型:

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

ASP.NET jQuery 食譜18 (通過使用jQuery valida

系統 2222 0

這節我們還可以通過直接設置DropDownList屬性來設置jQuery validation插件的校驗規則和提示信息。

先看界面代碼:

      
        <
      
      
        form 
      
      
        id
      
      
        ="form1"
      
      
         runat
      
      
        ="server"
      
      
        >
      
      
< div align ="center" >
< fieldset style ="width: 350px; height: 200px;" >
< table border ="0" cellpadding ="3" cellspacing ="3" >
< tr >
< td >
請選擇汽車類型:
</ td >
</ tr >
< tr >
< td >
< asp:DropDownList ID ="dllCar" runat ="server" ToolTip ="至少選擇一種車!" CssClass ="required" >
< asp:ListItem Value ="" Text ="---請選擇---" ></ asp:ListItem >
< asp:ListItem Value ="1" Text ="奔馳汽車" ></ asp:ListItem >
< asp:ListItem Value ="2" Text ="寶馬汽車" ></ asp:ListItem >
< asp:ListItem Value ="3" Text ="奧迪汽車" ></ asp:ListItem >
< asp:ListItem Value ="4" Text ="現代汽車" ></ asp:ListItem >
< asp:ListItem Value ="5" Text ="豐田汽車" ></ asp:ListItem >
</ asp:DropDownList >
</ td >
</ tr >
< tr >
< td >
< asp:Button ID ="btnSubmit" runat ="server" Text ="提交" />
</ td >
</ tr >
</ table >
</ fieldset >
< div id ="message" class ="alertmsg" >
</ div >
</ div >
</ form >

DropDownList控件屬性ToolTip會轉換為Title,title的值可以作為校驗規則required的提示信息,屬性CssClass的值required就指定了插件的校驗規則。

腳本代碼:

      
        <
      
      
        head 
      
      
        id
      
      
        ="Head1"
      
      
         runat
      
      
        ="server"
      
      
        >
      
      
< title > Recipe18 </ title >
< script type ="text/javascript" src ="Scripts/jquery-1.4.1-vsdoc.js" ></ script >
< script type ="text/javascript" src ="Scripts/jquery.validate.js" ></ script >
< script type ="text/javascript" >
$(
function () {
$(
" #form1 " ).validate({
errorLabelContainer: $( " #message " )
});
});
</ script >
< style type ="text/css" >
.alertmsg
{
color
: #FF0000 ;
}
</ style >
</ head >

顯示效果:

ASP.NET jQuery 食譜18 (通過使用jQuery validation插件校驗DropDownList)_第1張圖片

另外如果不設置DropDownList的屬性ToolTip和CssClass,腳本代碼改為如下,也可以實現同樣的效果:

      
        <
      
      
        script 
      
      
        type
      
      
        ="text/javascript"
      
      
        >
      
      
        
$(
function () {
$(
" #form1 " ).validate({
rules: { dllCar:
" required " },
messages: { dllCar:
" 至少選擇一種車! " },
errorLabelContainer: $(
" #message " )
});
});
</ script >



?




ASP.NET jQuery 食譜18 (通過使用jQuery validation插件校驗DropDownList)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 桃园市| 叙永县| 大庆市| 海晏县| 保康县| 海伦市| 卢湾区| 镇江市| 新兴县| 福清市| 莱州市| 会泽县| 博白县| 闵行区| 钟祥市| 呼伦贝尔市| 绿春县| 青浦区| 上蔡县| 家居| 中山市| 广平县| 福建省| 青浦区| 上饶市| 衡阳市| 沁阳市| 壤塘县| 德昌县| 新津县| 昌平区| 阜平县| 恭城| 麦盖提县| 张家界市| 普安县| 襄城县| 平乡县| 新绛县| 巫山县| 甘南县|