Blocking button when input textbox is empty asp.Net webforms
<p>I have a button and text control on my page.</p>

<pre><code>&lt;asp:TextBox ID="MyText" Width="100%" ClientIDMode="Static" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button ID="MyButton" OnClientClick="isNotEmpty()" CssClass="btn btn-primary" OnClick="Send_Click" ClientIDMode="Static" CausesValidation="false" runat="server" /&gt;
</code></pre>

<p>I am trying to make sure that it won't trigger OnClick if the textBox on the page is empty (or has whitespace). My code does not work and I have no clue why.</p>

<pre><code>function isNotEmpty() {
      if (&lt;%= MyText.Text.Length %&gt; &gt; 0)
        return true;
       return false;
    }
</code></pre>

<p>I also tried:</p>

<pre><code>function isNotEmpty(){
  document.getElementbyId("MyText").value !== null || document.getElementbyId("MyText").value.match(/^\s*$/) === null
}
</code></pre>