I'm trying to validate a form I have to make sure that at least one of the form elements is filled in. I am already using compare validators on a couple, so i decided to try the custom validator, even though it seems meant for only one control.
I created a dummy textbox to test this, here is the aspx code for it:
and here is the JS function, since i'm using OnClientValidate:
its doesn't even enter the function, just submits the form... anyone have any ideas?
Thanks.
I created a dummy textbox to test this, here is the aspx code for it:
Code:
<asp:TextBox id="txtValidate" runat="server"></asp:TextBox>
<br />
<asp:CustomValidator id="CustomValidator1" runat="server" ControlToValidate="txtValidate" ErrorMessage="You must fill in at least one field." Display="dynamic" OnClientValidate="verifyForm"></asp:CustomValidator>
and here is the JS function, since i'm using OnClientValidate:
Code:
<script language="javascript">
function verifyForm( oSrc, txtValue )
{
alert("test");
var found = 0;
for (var x = 0; x < document.Form1.length; x++) {
if (!(document.Form1.elements[x].value=="")) {
found = 1;
}
}
if (found == 0)
{
return false;
}
else
{
return true;
}
}
</script>
its doesn't even enter the function, just submits the form... anyone have any ideas?
Thanks.