title: How to bypass onSubmit Form validation in ASPX page
body: <p>i have a form on a particular ASPX page that has custom js validation. Also on this form is a navigation menu in the header.</p>
  
  <p>The navigation menu items are built programatically and are initiated by __doPostBack calls which obviously submits the form.</p>
  
  <p>The problem i am having is that the form itself has code something like the following</p>
  
  <pre><code>onsubmit='return validateForm()'
  </code></pre>
  
  <p>and if the form has not been filled out then the form cant submit. This in itself is not a problem unless a user goes to the form but decides to navigate away.</p>
  
  <p>When this happens the validateForm function fails.</p>
  
  <p>Does anyone have a workaround for this issue?</p>
  
  <p>NB: On my nav links i have already set CausesValidation="False"</p>
  
  <p>This is the markup:</p>
  
  <pre><code>&lt;div id="divNavigate" class="absolute_topleft"&gt;
      &lt;asp:LinkButton ID="linkGoHome" runat="server" OnClick="linkGoHome_Click" CausesValidation="false" CssClass="xxx"&gt;text.&lt;/asp:LinkButton&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the handler:</p>
  
  <pre><code>protected void linkGoHome_Click(object sender, EventArgs e)
  {
      Response.Redirect("xxxxx");
  }
  </code></pre>
  
  <p>This is the validation function:</p>
  
  <pre><code>function validateTextField(field) {
      var fieldElement = document.getElementById(field);    
      var validated = false;
  
      if (fieldElement.value.length &gt; 0) {
          validated = true;
      }            
  
      return validated;
  }
  </code></pre>
  
  <p>And this is how its called:</p>
  
  <pre><code>&lt;form id="formLogin" runat="server" onsubmit="return validateTextField(field1)"&gt;
  </code></pre>