Select box validation using JQuery

Introduction
In this article i will show you how to validate select box using JQuery. Example of select box validation using JQuery. First to get the id of the select box then get the value of it.

Source Code

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script>
        $(function () {
            $("#Button1").click(function () {
                var a = $("#d1").val();
                if(a=="0")
                {
                    alert("Please select");
                }

            });


        })
    </script>
</head>
<body>
    <select name="d11" id="d1">
        <option value="0" >Select</option>
        <option value="1">Apple</option>
    </select>
    <input id="Button1" type="button" value="button" />
</body>
</html>

Code generate the following output

Select box validation using JQuery

Comments

Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites