title: stop asp.net postback when UseSubmitBehavior="false"
body: <p>I have an asp.net button with UseSubmitBehavior="false"  like this:</p>
  
  <pre><code>  &lt;asp:Button ID="btnLogin" runat="server" UseSubmitBehavior="false"    OnClientClick="if (!LoginPopup()) {return false;}" CssClass="login-button" Text="&lt;%$ Resources: HRGELoggedOutMaster, Login %&gt;"&gt; &lt;/asp:Button&gt;
  </code></pre>
  
  <p>and js function like this:</p>
  
  <pre><code> function LoginPopup() {       
          var username = $("#&lt;%= UsernameTextBox.ClientID %&gt;").val();
          var password = $("#&lt;%= PasswordTextBox.ClientID %&gt;").val();
          var remMe;
          if ($('#&lt;%= chkRememberMe.ClientID %&gt;').attr('checked') == "checked") {
              remMe = true;
          }
          else {
              remMe = false;
          }
  
          if (username != '' &amp;&amp; password != '')
              CallPageMethod("LoginPopup", ["username", username, "password", password, "rememberMe", remMe], LoginPopupSucceeded, LoginPopupFailed);
          else
              alert("Invalid username/password");
              return false;
      }
  </code></pre>
  
  <p>and I call it on keypress of textboxes like this:</p>
  
  <pre><code>   $("#&lt;%=this.UsernameTextBox.ClientID%&gt;").keypress(function (event) {
             fireButtonClick($("#&lt;%=this.btnLogin.ClientID%&gt;"), event);
          });
  
  
  
   function fireButtonClick(ctrl, event) {
          if (event.which || event.keyCode) {
              if ((event.which == 13) || (event.keyCode == 13)) {
                  ctrl.click();
                  return false;
              }
  </code></pre>
  
  <p>I want to stop postback when input is invalid but It is not working. Please suggest me how to stop postback</p>