title: dynamically remove an element's required attribute in ASP MVC?
body: <p>Is there a way, in an ASP MVC project using unobtrusive validation, to dynamically remove the Required attribute from an element?</p>
  
  <p>The element is decorated with a Required annotation in the view model.  I thought I could remove this by removing the html attribute, "data-val-required," with JQuery but client validation still treats the element as required.  Is it impossible to manipulate the element's validation by manipulating the unobtrusive validation attributes?</p>
  
  <p>This is what I tried, but it didn't work.  I wanted to remove the required attribute if a check box was unchecked.</p>
  
  <pre><code>$("#chkTempHire").click(function () {
  
      var checked = $(this).attr("checked");
      var attr = $("#txtTempHireEndDate").attr("data-val-required");
      var hasAttr = false;
  
      if (typeof attr !== typeof undefined &amp;&amp; attr !== false)
          hasAttr = true;
  
      if (!checked &amp;&amp; hasAttr)
          $("#txtTempHireEndDate").removeAttr("data-val-required");
  });
  </code></pre>
  
  <p>Am I missing something, or is it just not possible?</p>
  
  <p>Thank you!</p>