ASP.NETjQuery實例16通過控件CustomValidator驗證RadioButtonList

界面代碼:
文章來自 codego.net 請看源代碼:
<form id="form1" runat="server">
<div align="center">
<fieldset >
<table border="0" cellpadding="3" cellspacing="3">
<tr>
<td>
請選擇汽車類型:
</td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="rbCar" 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="現代汽車"></asp:ListItem>
<asp:ListItem Value="5" Text="豐田汽車"></asp:ListItem>
</asp:RadioButtonList>
</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="rbCar_Validation"></asp:CustomValidator>
</div>
</form>

腳本代碼:
文章來自 codego.net 請看源代碼:
<head id="Head1" runat="server">
<title>Recipe16</title>
<script type="text/javascript" src="Scripts/jquery-1.4.1-vsdoc.js"></script>
<script type="text/javascript">
function rbCar_Validation(sender, args) {
args.IsValid = ($("#rbCar :radio:checked").length > 0);
}
</script>
</head>

顯示效果:

網頁標題:ASP.NETjQuery實例16通過控件CustomValidator驗證RadioButtonList
本文URL:http://muchs.cn/article6/gecjig.html

成都網站建設公司_創(chuàng)新互聯,為您提供微信小程序、網站內鏈、網站建設、小程序開發(fā)搜索引擎優(yōu)化、App開發(fā)

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

外貿網站建設