Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to compare textbox value and listbox value using jquery??
Posted
Comments
♥…ЯҠ…♥ 22-Nov-13 7:08am    
How many values do listbox have?

1 solution

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JQuery.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {

            $('#btn').click(function () {

                var isEqual = $('#txtbox').val() == $('#lstbox').val();
                alert(isEqual ? "Same" : "different");
                return false;

            });
        });

        debugger;
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btn" runat="server" Text="Compare" />
        <asp:TextBox ID="txtbox" runat="server">
        </asp:TextBox>
        <br />
        <asp:ListBox ID="lstbox" runat="server">
            <asp:ListItem Text="aaaa" />
            <asp:ListItem Text="bbbb" />
            <asp:ListItem Text="cccc" />
        </asp:ListBox>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
Comments
♥…ЯҠ…♥ 22-Nov-13 7:15am    
Nice!!!
Karthik_Mahalingam 22-Nov-13 7:30am    
Thanks :)

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