Tuesday, October 6, 2015

Enable And Disable

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                //Listen for a key up event on the search input
                $('#txt_search').keyup(function () {
                    //When a user presses and releases a key
                    //Check to see if the length of the inputted
                    //data is greater than 2
                    if ($(this).val().length > 2) {
                        //If the input length is greater than
                        //two then we enable the search button
                        $('#btn_search').prop("disabled", false);
                    } else {
                        //If the input length is equal to 2 or less we disable the search button
                        $('#btn_search').prop("disabled", true);
                    }
                });
            });
        </script>
      
        <asp:TextBox ID="txt_search" runat="server"></asp:TextBox>
        <asp:Button ID="btn_search" runat="server" Text="Search" disabled />
        <asp:TextBox ID="txt_search" runat="server"></asp:TextBox>

        <asp:Button ID="btn_search" runat="server" Text="Search" disabled />