Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为JQuery验证向RadioButtonList输入添加属性_C#_Jquery_Asp.net_Jquery Validate - Fatal编程技术网

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('必需','');
});
上述代码将把所有
必需的
属性插入单选按钮列表中的所有输入