ASP.NET jQuery 实例16 通过控件CustomValidator验证RadioButtonList
2014-03-03 19:12
651 查看
界面代码:
文章来自 codego.net 请看源代码:
<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: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>
显示效果:
文章来自 codego.net 请看源代码:
<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: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.NET jQuery 实例16 通过控件CustomValidator验证RadioButtonList
- ASP.NET jQuery 实例16 通过控件CustomValidator验证RadioButtonList
- ASP.NET jQuery 实例15 通过控件CustomValidator验证CheckBoxList
- ASP.NET jQuery 实例15 通过控件CustomValidator验证CheckBoxList
- ASP.NET jQuery 食谱15 (通过控件CustomValidator验证CheckBoxList)
- ASP.NET jQuery 食谱16 (通过控件CustomValidator验证RadioButtonList)
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- ASP.NET jQuery 实例12 通过使用jQuery validation插件简单实现用户注册页面验证功能
- ASP.NET jQuery 实例9 通过控件hyperlink实现返回顶部效果
- ASP.NET jQuery 实例12 通过使用jQuery validation插件简单实现用户注册页面验证功能
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- ASP.NET jQuery 实例9 通过控件hyperlink实现返回顶部效果
- 牛腩购物12 :整合用户登录页 用到 asp.net 内置票据认证控件的使用(用户登录 用户权限) 用户控件ascx 设置/获取RadioButtonList 和RadioButton
- 表单验证ASP.NET RequiredFieldValidator 控件使用方法及使用实例
- ASP.Net中通过Jquery前端对Repeater控件绑定的数据进行操作
- ASP.NET验证控件:CustomValidator 定制函数验证
- ASP.NET jQuery 实例7 通过jQuery来获取DropDownList的Text/Value属性值
- VS2012使用验证控件出现[ASP.NET]WebForms UnobtrusiveValidationMode 需要 'jquery' 的 ScriptResourceMapping。請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)。的解决办法。
- ASP.NET验证控件应用实例与详解
- ASP.NET控件之RadioButtonList详解