C# 为JQuery验证向RadioButtonList输入添加属性
如何将C# 为JQuery验证向RadioButtonList输入添加属性,c#,jquery,asp.net,jquery-validate,C#,Jquery,Asp.net,Jquery Validate,如何将required添加到我认为在单选按钮组上启用JQuery validation所需的输入字段之一 我可以通过执行以下操作将required添加到RadioButtonList控件 rbSeverity.Attributes.Add(“必需的”、“必需的”) 但是如何将此属性添加到从控件生成的输入之一 <asp:RadioButtonList ID="rbSeverity" RepeatDirection="Horizontal" RepeatLayout="Flow"
required
添加到我认为在单选按钮组上启用JQuery validation
所需的输入字段之一
我可以通过执行以下操作将required
添加到RadioButtonList
控件
rbSeverity.Attributes.Add(“必需的”、“必需的”)代码>
但是如何将此属性添加到从
控件生成的输入之一
<asp:RadioButtonList ID="rbSeverity" RepeatDirection="Horizontal" RepeatLayout="Flow"
runat="server" >
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:RadioButtonList>
1.
2.
3.
您可以使用jQuery执行此操作:
$(function () {
$('#<%= rbSeverity.ClientID %> input').attr('required', '');
});
$(函数(){
$('输入').attr('必需','');
});
上述代码将把所有必需的属性插入单选按钮列表中的所有输入