validating the drop down list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shivu bagalkot
    New Member
    • Aug 2010
    • 1

    validating the drop down list

    Please any body hel me out for validating the drop down list, that list contains 5 values if it is not selected then it should give errormessage



    Thanks in advance
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    You can do something like this in javascript

    Code:
    var e = document.getElementById("dropdownname"); 
    var datavalue = e.options[e.selectedIndex].value; 
    var datatext = e.options[e.selectedIndex].text;
    Then verify if it is blank or null
    Last edited by Frinavale; Aug 27 '10, 08:13 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags (replaced the bold tags with code tags)

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You should also do server-side validation (in your VB.NET or C# code).

      Just check if the DropDownList.Se lectedValue is something :)

      -Frinnt

      Comment

      Working...