dropdownlist and Custom validation

G

gane kol

Hi

I have a custom validator that validates a drop downlist which has a
listitem value as "". but it is not working.
But if i assign "0" for the list item and check for "0" in javascript, it
works fine. Any ideas?

for eg:
<asp:DropDownList id=DropDownList1 runat="server">
<asp:ListItem Value="">select</asp:ListItem>
<asp:ListItem Value="1">test1</asp:ListItem>
<asp:ListItem Value="2">test2</asp:ListItem>
</asp:DropDownList>
<asp:CustomValidator id=CustomValidator1 runat="server"
ControlToValidate="DropDownList1" ErrorMessage="errrrrrrr"
ClientValidationFunction="testddl"></asp:CustomValidator>

function testddl(source, arguments) { var ddlDropDownList1 =
document.Form1.DropDownList1.options[document.Form1.DropDownList1.selectedIn
dex].value; if (ddlDropDownList1 == "") { arguments.IsValid = false; } }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top