title: Stopping button OnClick event with javascript
body: <p>I'm trying to run some javascript before my button's click event happens on the server side, but the javascript code runs, and the server side code runs right after that no matter what. Here's what I have:</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
    $(document).ready(function() {
      SubmitClick = function() {
          if ($("#&lt;%= fuFile.ClientID %&gt;").val() == "") {
              $("#error").html("File is required");
  
              return false;
          }
      }
    });
  &lt;/script&gt;
  
  &lt;asp:FileUpload ID="fuFile" runat="server" /&gt;
  
  &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit"
    OnClientClick="SubmitClick()" UseSubmitBehavior="false"
    OnClick="btnSubmit_Click" /&gt;
  
  &lt;span id="error"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>I thought that setting <code>UseSubmitBehavior="false"</code> and returning <code>false</code> in the javascript function would work, but it's not. My error message gets displayed for a second before the server side code runs.</p>
  
  <p>What am I doing wrong here?</p>