<asp:HiddenField ID=”hdnLength” runat=”server” />
<div>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” >
<asp:ListItem Text=”One” Value=”1″ >asp:ListItem>
<asp:ListItem Text=”Two” Value=”2″ >asp:ListItem>
<asp:ListItem Text=”Three” Value=”3″ >asp:ListItem>
<asp:ListItem Text=”Four” Value=”4″ >asp:ListItem>
<asp:ListItem Text=”Five” Value=”5″ >asp:ListItem>
asp:CheckBoxList>
<asp:CustomValidator ID=”cust” runat=”server” ErrorMessage=”Please select “
ClientValidationFunction=”Validate” Display=”Dynamic” >asp:CustomValidator>
<asp:Button ID=”Button1″ runat=”server” Text=”Button” CausesValidation=”true” />
div>
<script type=”text/javascript” language=”javascript” >
function Validate(sender, args)
{
var Count =0 ;
var length = document.getElementById(”).value;
for(var i = 0 ; i < length; i++)
{
if(document.getElementById(“CheckBoxList1_” + i))
{
if(document.getElementById(“CheckBoxList1_” + i).checked == true)
{
Count = 1;
break;
}
else
{
}
}
}
if(Count == 0)
args.IsValid = false;
else
args.IsValid = true;
}
script>
protected void Page_Load(object sender, EventArgs e)
{
hdnLength.Value = “5″;
}