Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Validator Combo Box ASP.NET

Posted on 2009-03-31
4
Medium Priority
?
491 Views
Last Modified: 2013-12-17
Hi,

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.

thanks
0
Comment
Question by:kinton
[X]
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
4 Comments
 
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
 
Anurag
 


0
 
LVL 2

Author Comment

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

Accepted Solution

by:
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
 
Anurag
0
 
LVL 2

Author Closing Comment

by:kinton
ID: 31564749
Great, thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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