469,323 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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 4552
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.