title: Javascript validation for empty textbox on button click in asp.net
body: <p>I have asp.net application with one panel.
  Inside that panel i have one image button and <code>textbox</code>.
  I have written a javascript validation function for textbox which will display alert box for entering some values in <code>textbox</code>.
  Now this function is not working gave run-time error: </p>
  
  <blockquote>
    <p>Object required</p>
  </blockquote>
  
  <p>My code is here:</p>
  
  <pre><code>&lt;asp:Panel ID="pnlTop" runat="server"&gt;
     &lt;tr height="35px" valign="top"&gt;
        &lt;td align="right" valign="middle" colspan="2" height="50"&gt;
           &lt;asp:ImageButton ID="imgbtnGOTO" runat="server" ToolTip="View Specific Record" BorderWidth="0"
                                  ImageAlign="AbsMiddle" OnClientClick="javascript:return fnCheck()"&gt;&lt;/asp:ImageButton&gt;&amp;nbsp;&amp;nbsp;
           &lt;asp:TextBox ID="txtPagingGoto" CssClass="clsTableCellLeft" Width="215px" runat="server" CausesValidation="true"&gt;&lt;/asp:TextBox&gt;
        &lt;/td&gt;
     &lt;/tr&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>My Javascript function is:</p>
  
  <pre><code>function fnCheck() {
      if ((document.getElementById("txtPagingGoto").value).length == 0) {
          alert("The textbox should not be empty");
      }
  }
  </code></pre>
  
  <p>Please suggest solution for this.</p>