Solved

Validator Combo Box ASP.NET

Posted on 2009-03-31
4
474 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 500 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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