Validator Combo Box ASP.NET

Posted on 2009-03-31
Medium Priority
Last Modified: 2013-12-17

I have a combo box on my ASP.NET page.  The first entry is "Please Select" with a value of 0.

I want to put a client side validator on the page that will force the user to select a value other than please select.  I have other validators against text boxes so need the warning to appear as if it was a standard ASP.NEt validator.

Question by:kinton
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 11

Expert Comment

by:Anurag Agarwal
ID: 24027367
if(document.getElementById('<%=combobox.ClientID%>' ).selectedIndex == 0)
alert("Please select any option");
document.getElementById("<%=ddlDrop.ClientID%>").f ocus();
return false;
put this code in a javascript function & call that javascript function on the click click of button or the lost focus event of combobox


Author Comment

ID: 24027420
Do you need to pass anything into the Java script function?
LVL 11

Accepted Solution

Anurag Agarwal earned 2000 total points
ID: 24027578
nothing in the above code.
make sure when you call this javascript function on click event write somethig like this
onclick="return Validate()"
if Validate is the name of the javascript function

Author Closing Comment

ID: 31564749
Great, thanks

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question