title: ASP.Net form validation - bypass client side only on button click
body: <p>I have a form with a bunch of fields that I am using RequiredFieldValidator, RegularExpressionValidator, and CustomValidator.</p>
  
  <p>I want my form to perform client side checks when tabbing between fields (it currently does this), but I want to force a server side submit when the asp:button is clicked.  Right now, if a form field is determined invalid on the client side, the submit button doesn't do anything.  I want it to submit the page and perform the server side check.  </p>
  
  <p>The reason I want this to happen is because I want the page to go back to the top and display all possible issues and make it obvious to the user that there was a problem.  Currently if they didn't see the client side error message, they may just click submit, see nothing happen, and end up confused. </p>
  
  <p>Example field on aspx Page:</p>
  
  <pre><code>&lt;asp:TextBox MaxLength="30" ID="LNom" runat="server" /&gt;&lt;asp:RequiredFieldValidator ID="reqLNom" runat="server" ErrorMessage="Last Name Required" ControlToValidate="LNom" /&gt;&lt;asp:CustomValidator ID="valLNom" runat="server" ErrorMessage="Please enter a valid last name (less than 30 characters in length)." ControlToValidate="LNom" OnServerValidate="ValidationLastName" /&gt;
   &lt;asp:Button ID="Submit" Text="Submit" runat="server" onclick="Submit_Click" /&gt;
  </code></pre>
  
  <p>Submit button Code Behind:</p>
  
  <pre><code>protected void Submit_Click(object sender, EventArgs e)
  {
      Page.Validate();
      if (Page.IsValid)
      {
        // Do stuff
      }
  }
  </code></pre>
  
  <p>Obviously there is a bit more to this, but you get the idea. </p>