http://www.w3.org/1999/xhtml"> function checkIssueType(source, args) { var chkListaTipoModificaciones = d_c#中web应用程序如何设置requiredfieldvalidator组件">
赞
踩
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckboxlistDemo._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function checkIssueType(source, args) {
var chkListaTipoModificaciones = document.getElementById('<%= IssueTypeCheckBox.ClientID %>');
var chkLista = chkListaTipoModificaciones.getElementsByTagName("input");
for (var i = 0; i < chkLista.length; i++) {
if (chkLista[i].checked) {
args.IsValid = true;
return;
}
}
args.IsValid = false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:CheckBoxList ID="IssueTypeCheckBox" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Hardware</asp:ListItem>
<asp:ListItem Value="2">Software </asp:ListItem>
<asp:ListItem Value="3">Mechanical</asp:ListItem>
<asp:ListItem Value="4">Others</asp:ListItem>
</asp:CheckBoxList>
</td>
<td>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="*" ClientValidationFunction="checkIssueType"></asp:CustomValidator>
</td>
</tr>
<tr>
<td><asp:Button runat="server" ID="btn" Text="Submit"/></td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。