Click here to Skip to main content
14,934,560 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Apply validation on dropdownlist in Me appropriate Answer
bbirajdar 25-Apr-12 9:29am
@anilsrk...Are these answers given below appropriate? Please comment..
Sandeep Mewara 25-Apr-12 11:22am

Well, I assume you just want to validate that a specific item is not selected. Try using jQuery:

function validate() {
     if ($('#myDropDownList option:selected').val() == 'The wrong value') {
         return false;
         return true;

On the onchange event of the drop down call the validate function.
You can try like this..

<script runat="server">

    void btnSubmit_Click(Object sender, EventArgs e)
        if (Page.IsValid)
            lblResult.Text = dropFavoriteColor.SelectedValue;
I assume you just want to validate that a user changes the index of dropdown from 0 to 1 or more

Use required field validator and set the initialize property of your dropdownlist.

If this not helps feel free to ask the doubt

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900