471,830 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,830 software developers and data experts.

Javascript custom validator problem on DropDownList

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
1 4609
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.

Similar topics

reply views Thread by Tom Pearson | last post: by
2 posts views Thread by Pham Nguyen | last post: by
reply views Thread by Vi | last post: by
3 posts views Thread by useenmelately | last post: by
2 posts views Thread by Bas Groeneveld | last post: by
reply views Thread by tsw_mik | last post: by
1 post views Thread by Joey | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.