A
Assimalyst
Hi,
I'm attempting to write a piece of code that acts as a client side
validator for all drop down lists on a webform, giving an error if the
SelectedIndex = 0.
Here is what i have:
function clientValidateDDL(source, args)
{
var dropdown = document.getElementById(source.controltovalidate);
if (dropdown.selectedindex == 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
However, it does not give an error for any selected index, including
index 0, so i'm presuming the var dropdown = ... line is not correctly
selecting the dropdownlist that launched the function.
ClientValidationFunction="clientValidateDDL" is inserted in the
custom
validator tags. and ControlToValidate is also present and correct.
Any ideas?
Thanks.
I'm attempting to write a piece of code that acts as a client side
validator for all drop down lists on a webform, giving an error if the
SelectedIndex = 0.
Here is what i have:
function clientValidateDDL(source, args)
{
var dropdown = document.getElementById(source.controltovalidate);
if (dropdown.selectedindex == 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
However, it does not give an error for any selected index, including
index 0, so i'm presuming the var dropdown = ... line is not correctly
selecting the dropdownlist that launched the function.
ClientValidationFunction="clientValidateDDL" is inserted in the
custom
validator tags. and ControlToValidate is also present and correct.
Any ideas?
Thanks.