亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ASP.NET jQuery 實(shí)例15 通過(guò)控件CustomValidator驗(yàn)證CheckBoxList

 更新時(shí)間:2012年02月03日 17:24:32   作者:  
這節(jié)我們要講下如何通過(guò)控件CustomValidator來(lái)校驗(yàn)CheckBoxList,客戶端校驗(yàn)代碼通過(guò)jQuery實(shí)現(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>
請(qǐng)選擇汽車類型:
</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ù)說(shuō)明:
ErrorMessage:設(shè)置校驗(yàn)提示信息
Display:設(shè)置顯示模式,Dynamic表示提示信息不顯示的時(shí)候,不占用當(dāng)前位置
ClientValidationFunction:設(shè)置定義客戶端自定義校驗(yàn)函數(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控件通過(guò)自定義函數(shù)的參數(shù)args屬性IsValid來(lái)判斷是否驗(yàn)證通過(guò)
args.IsValid = ($("#chkCar input:checked").length >= 3);
}
</script>
</head>

最終顯示效果:

相關(guān)文章

最新評(píng)論