Check Control has Value or Not in JQuery

This blog, I will explain how to check if the control have value or not using JQuery.

  1. <head id="Head1" runat="server">  
  2. <title></title>  
  3. <script src="JS/jquery-1.3.2.min.js" type="text/javascript"></script>  
  4. <script type="text/javascript">  
  5.     $(document).ready(function () {  
  6.         $("#btnGet").click(function () {  
  7.             if ($("#TextBox1").val() != 0)  
  8.             { alert("text box is not empty"); }  
  9.             else {  
  10.                 alert("text box is empty");  
  11.             }  
  12.         });  
  13.     });  
  14. </script>  
  15. </head>  
  16. <body>  
  17. <form id="form1" runat="server">  
  18. <div style="padding-left: 100px">  
  19. <br />  
  20. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
  21. <asp:Button ID="btnGet" runat="server" Text="Check If value Exists" OnClick="btnGet_Click" />  
  22. </div>  
  23. </form>  
  24. </body>  
Output

Then the Textbox has not value:

page at local host

And the Textbox has value:
textbox is not empty

Next Recommended Reading How To Check Password Strength In jQuery