最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET jQuery 實例15 通過控件CustomValidator驗證CheckBoxList

 更新時間:2012年02月03日 17:24:32   作者:  
這節(jié)我們要講下如何通過控件CustomValidator來校驗CheckBoxList,客戶端校驗代碼通過jQuery實現(xiàn)
首先看下界面代碼:
復(fù)制代碼 代碼如下:

<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:CheckBoxList ID="chkCar" runat="server">
<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="現(xiàn)代汽車"></asp:ListItem>
<asp:ListItem Value="5" Text="豐田汽車"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="提交" />
</td>
</tr>
</table>
</fieldset>
<asp:CustomValidator ID="ctvCar" runat="server" Display="Dynamic" ErrorMessage="至少選擇三種車!"
ForeColor="Red" ClientValidationFunction="ctvCar_Validation"></asp:CustomValidator>
</div>
</form>

控件CustomValidator相關(guān)參數(shù)說明:
ErrorMessage:設(shè)置校驗提示信息
Display:設(shè)置顯示模式,Dynamic表示提示信息不顯示的時候,不占用當前位置
ClientValidationFunction:設(shè)置定義客戶端自定義校驗函數(shù)
客戶端腳本代碼:
復(fù)制代碼 代碼如下:

<head id="Head1" runat="server">
<title>Recipe15</title>
<script type="text/javascript" src="Scripts/jquery-1.4.1-vsdoc.js"></script>
<script type="text/javascript">
function ctvCar_Validation(sender, args) {
// CustomValidator控件通過自定義函數(shù)的參數(shù)args屬性IsValid來判斷是否驗證通過
args.IsValid = ($("#chkCar input:checked").length >= 3);
}
</script>
</head>

最終顯示效果:

相關(guān)文章

最新評論

东丰县| 乳山市| 漳平市| 准格尔旗| 麦盖提县| 施甸县| 小金县| 历史| 西盟| 金沙县| 冕宁县| 新余市| 响水县| 武清区| 清涧县| 墨玉县| 凭祥市| 辽源市| 贡觉县| 无锡市| 玉林市| 卢龙县| 肥东县| 山西省| 衡阳县| 广饶县| 涞水县| 九江县| 扎囊县| 平谷区| 陆河县| 司法| 田阳县| 门头沟区| 台前县| 琼海市| 府谷县| 疏附县| 准格尔旗| 吕梁市| 姜堰市|