By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

Javascript custom validator problem on DropDownList

P: n/a
Hi,

I'm pretty new to javascript and i'm struggling to get a custom
validator working.

I have a dropdownlist populated by a datareader, the top value of which
is always "Please Select..." at index 0.

How can i code a validator to be invalid if "Please Select..." is
selected, but valid for any other value?

Here is my attempt:

function validateSurgeonNameDDL(oSrc, args)
{
args.IsValid = ([surgeonNameDDL.SelectedIndex].Value != "0");
}

However, this comes back invalid, for all selection.

Thanks.

Aug 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Assimalyst wrote:
Hi,

I'm pretty new to javascript and i'm struggling to get a custom
validator working.

I have a dropdownlist populated by a datareader, the top value of which
is always "Please Select..." at index 0.

How can i code a validator to be invalid if "Please Select..." is
selected, but valid for any other value?

Here is my attempt:

function validateSurgeonNameDDL(oSrc, args)
{
args.IsValid = ([surgeonNameDDL.SelectedIndex].Value != "0");
}


function somethingSelected(dropdownlist){
return dropdownlist.selectedIndex>0;
}

function validateForm(form){
var msg="";
if(!somethingSelected(form.SELECTNAMEHERE)) {
msg+="Please select a surgeon\n";
}

....
if(msg){alert(msg);return false;}
return true;
}
Mick
Aug 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.