This blog, I will explain how to check if the control have value or not using JQuery.
- <head id="Head1" runat="server">
- <title></title>
- <script src="JS/jquery-1.3.2.min.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- $("#btnGet").click(function () {
- if ($("#TextBox1").val() != 0)
- { alert("text box is not empty"); }
- else {
- alert("text box is empty");
- }
- });
- });
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div style="padding-left: 100px">
- <br />
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
- <asp:Button ID="btnGet" runat="server" Text="Check If value Exists" OnClick="btnGet_Click" />
- </div>
- </form>
- </body>
Output
Then the Textbox has not value:
And the Textbox has value: