In this article I will explain how to validate (check) ASP.Net DropDownList using JavaScript and jQuery.
 
Validate (Check) ASP.Net DropDownList using JavaScript
The following HTML Markup consists of an ASP.Net DropDownList and a Button. The ASP.Net Button has been assigned a JavaScript OnClick event handler.
When the Button is clicked, the Validate JavaScript function is executed.
Inside the function, the ASP.Net DropDownList object is referenced and if the selected value matches the value of the default item then an error message is displayed using JavaScript alert message box.
Select Fruit:
<asp:DropDownList ID="ddlFruits" runat="server">
    <asp:ListItem Text="Please Select" Value=""></asp:ListItem>
    <asp:ListItem Text="Mango" Value="1"></asp:ListItem>
    <asp:ListItem Text="Apple" Value="2"></asp:ListItem>
    <asp:ListItem Text="Orange" Value="3"></asp:ListItem>
</asp:DropDownList>
<asp:Button Text="Validate" runat="server" OnClientClick="return Validate()" />
<script type="text/javascript">
    function Validate() {
        var ddlFruits = document.getElementById("<%=ddlFruits.ClientID %>");
        if (ddlFruits.value == "") {
            //If the "Please Select" option is selected display error.
            alert("Please select an option!");
            return false;
        }
        return true;
    }
</script>
 
 
Validate (Check) ASP.Net DropDownList using jQuery
The following HTML Markup consists of an ASP.Net DropDownList and a Button. The ASP.Net Button has been assigned a jQuery OnClick event handler.
Inside the jQuery OnClick event handler, the ASP.Net DropDownList object is referenced and if the selected value matches the value of the default item then an error message is displayed using JavaScript alert message box.
Select Fruit:
<asp:DropDownList ID="ddlFruits" runat="server">
    <asp:ListItem Text="Please Select" Value=""></asp:ListItem>
    <asp:ListItem Text="Mango" Value="1"></asp:ListItem>
    <asp:ListItem Text="Apple" Value="2"></asp:ListItem>
    <asp:ListItem Text="Orange" Value="3"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSubmit" Text="Validate" runat="server" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("[id*=btnSubmit]").click(function () {
            var ddlFruits = $("[id*=ddlFruits]");
            if (ddlFruits.val() == "") {
                //If the "Please Select" option is selected display error.
                alert("Please select an option!");
                return false;
            }
            return true;
        });
    });
</script>
 
 
Screenshot
Validate (Check) ASP.Net DropDownList using JavaScript and jQuery
 
 
Demo
 
 
Downloads

Download Code