title: asp button prevent post back on javascript function return false
body: <p>I am trying to prevent post back when javascript function returns false, but still post back occurs. I don't understand what I am missing in this code. I have searched in internet and they showed the same solution. </p>
  
  <pre><code>function chkMemName() {
              var valMemName = document.getElementById('&lt;%= txtMemName.ClientID %&gt;').value;
  
              if (valMemName.length == 0) {
                  alert("member name missing!!!");
                  txtMemName.focus();
                  return false;
              }
          }
  
  &lt;label&gt;MEM NAME&lt;/label&gt;
  &lt;input type="text" maxlength="200" runat="server" id="txtMemName" autocomplete="off" /&gt;
  
  &lt;asp:Button ID="btnAddFamily" runat="server" OnClientClick="chkMemName(); return false;" ClientIDMode="Static" formnovalidate="formnovalidate" OnClick="btnAddFamily_Click" Text="ADD" /&gt;
  </code></pre>