title: How to exclude a control from ASP.NET validation when hidden (display:none;)?
body: <p><strong>HOW TO EXCLUDE A CONTROL FROM ASP.NET VALIDATION WHEN HIDDEN?</strong></p>
  
  <ul>
  <li><p>A checkbox is used to alternate between two textboxs.</p></li>
  <li><p>Either one or the other is required <strong>NOT BOTH</strong>.</p></li>
  <li><p>I want the required field to disabled when hidden.</p></li>
  </ul>
  
  <p>I am aware <code>enabled="false"</code> and <code>visible="false"</code> create this behaviour however I want to maintain the jquery fade in out animation.</p>
  
  <p>I tried to add disabled false property to javascript but couldn't get it to work.
  Other solutions found online don't seem to achieve what is needed.</p>
  
  <p><strong>ASP.NET</strong></p>
  
  <pre><code>&lt;div class="Hide1"&gt;
    &lt;asp:TextBox ID="tb" runat="Server"/&gt;
    &lt;asp:RequiredFieldValidator ID="rfv1" RunAt="Server" ControlToValidate="tb"/&gt;
  &lt;/div&gt;
  
  &lt;div class="Hide2"&gt;
    &lt;asp:TextBox ID="tb2" runat="Server"/&gt;
    &lt;asp:RequiredFieldValidator ID="rfv2" RunAt="Server" ControlToValidate="tb2"/&gt;
  &lt;/div&gt;
  
  &lt;asp:Button ID="btn" runat="Server" Text="GO"/&gt;
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>  $('.tb').hide();
    $('#CB').change(function () {
      if ($(this).is(':checked')) {
        $('.tb2').fadeOut(100, function () {
          $('.tb').fadeIn();
        });
      } else {
        $('.tb').fadeOut(100, function () {
          $('.tb2').fadeIn();
        });
      }
    });
  </code></pre>