gpt4 book ai didi

javascript - Telerik 单选按钮所需的字段验证器

转载 作者:行者123 更新时间:2023-11-27 23:31:39 29 4
gpt4 key购买 nike

如何为 Telerik 单选按钮设置必填字段验证器?我想在按钮单击“BtnSave”时设置必填字段验证器?请帮忙!

<telerik:RadButton ID="radio_male" runat="server" ToggleType="Radio" AutoPostBack="false" GroupName="gender"
Text="Male" Skin="Metro">
<ToggleStates>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked"></telerik:RadButtonToggleState>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio"></telerik:RadButtonToggleState>
</ToggleStates>
</telerik:RadButton>

<telerik:RadButton ID="radio_female" runat="server" ToggleType="Radio" AutoPostBack="false" GroupName="gender"
Text="Female" Skin="Metro">
<ToggleStates>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked"></telerik:RadButtonToggleState>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio"></telerik:RadButtonToggleState>
</ToggleStates>
</telerik:RadButton>

最佳答案

我们不能直接在 radbutton 上应用验证器控件,但我们可以通过使用下面的代码片段来实现给定的要求。

<head runat="server">
<title></title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function ClientClicked(sender, args) {
var txt = $("#<%=radio_txt.ClientID%>");
txt.val("test");
}
</script>
</telerik:RadCodeBlock>

</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
<telerik:RadButton ID="radio_male" runat="server" ToggleType="Radio" AutoPostBack="false" GroupName="gender"
Text="Male" Skin="Metro" OnClientClicked="ClientClicked">

<ToggleStates>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked"></telerik:RadButtonToggleState>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio"></telerik:RadButtonToggleState>
</ToggleStates>
</telerik:RadButton>

<telerik:RadButton ID="radio_female" runat="server" ToggleType="Radio" AutoPostBack="false" GroupName="gender"
Text="Female" Skin="Metro" OnClientClicked="ClientClicked">
<ToggleStates>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadioChecked"></telerik:RadButtonToggleState>
<telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleRadio"></telerik:RadButtonToggleState>
</ToggleStates>
</telerik:RadButton>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="Gender" ControlToValidate="radio_txt" ErrorMessage="required !!"></asp:RequiredFieldValidator>
<div style="display: none;">
<asp:TextBox ID="radio_txt" runat="server" ValidationGroup="Gender"></asp:TextBox>

</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click me" ValidationGroup="Gender" />
</div>
</form>
</body>

如果有任何疑问,请告诉我。

关于javascript - Telerik 单选按钮所需的字段验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34521211/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com