使用必填字段验证器在asp.net中验证复选框的代码 [英] Code for Validating Checkbox in asp.net with required field validator
本文介绍了使用必填字段验证器在asp.net中验证复选框的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
请在asp.net中使用必填字段验证器提供验证复选框的asp.net代码。
谢谢
Chandra
Please provide the asp.net code Code for Validating Checkbox in asp.net with required field validator.
Thanks
Chandra
推荐答案
您需要使用自定义验证器CheckBoxes。
参考
http://www.aspsnippets.com/Articles/ASP.Net-CheckBox-Required-Validation-using-Custom -Validator-and-JavaScript.aspx [ ^ ]
希望这可以帮助你......
You need to use a custom validator for CheckBoxes.
Refer
http://www.aspsnippets.com/Articles/ASP.Net-CheckBox-Required-Validation-using-Custom-Validator-and-JavaScript.aspx[^]
Hope this helps you...
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type = "text/javascript">
function ValidateCheckBox(sender, args) {
if (document.getElementById("<%=CheckBox1.ClientID %>").checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Required" ClientValidationFunction = "ValidateCheckBox"></asp:CustomValidator><br />
<asp:Button ID="Button1" runat="server" Text="Submit"/>
</form>
</body>
</html>
http://stackoverflow.com/questions/11080251/validate-checkbox-asp-net- c-sharp [ ^ ]
试试这个
http://stackoverflow.com/questions/11080251/validate-checkbox-asp-net-c-sharp[^]
Try this
这篇关于使用必填字段验证器在asp.net中验证复选框的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文