Abdu_Allah
asked on
CustomValidator problem
I am trying to validate listbox by CustomValidator control using client script but the clien script function is not fired!
Here is my code, what I am doin wrong?
<asp:listbox id="Departments" runat="server" Width="160px" SelectionMode="Multiple">< /asp:listb ox>
<asp:CustomValidator id="Departmentsvld" runat="server" ControlToValidate="Departm ents" ClientValidationFunction=" HasDepartm ent" Text="*" />
<script>
function HasDepartment(source, arguments)
{
alert("Fired");
for(var i=0; i < document.getElementById('D epartments ').length; i++)
{
if(document.getElementById ("Departme nts")[i].s elected)
{
arguments.IsValid = true;
return;
//this is selected
}
}
arguments.IsValid = false;
}
</script>
Here is my code, what I am doin wrong?
<asp:listbox id="Departments" runat="server" Width="160px" SelectionMode="Multiple"><
<asp:CustomValidator id="Departmentsvld" runat="server" ControlToValidate="Departm
<script>
function HasDepartment(source, arguments)
{
alert("Fired");
for(var i=0; i < document.getElementById('D
{
if(document.getElementById
{
arguments.IsValid = true;
return;
//this is selected
}
}
arguments.IsValid = false;
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.