title: Disable required validation by JavaScript
body: <p>I have a create form to create an object.
  The create model has some properties that are only visible (.hide, .show()) if a checkbox is checked and that are marked required (by Attribute in Model).</p>
  
  <p>Unfortunatly when the checkbox is not checked, the required validation is performed on the properties hidden.</p>
  
  <p>How can I disable the required validation for this properties?</p>
  
  <p>I tried setting the data-val property of the input element to false but this does not work.</p>
  
  <p>Some an idea?</p>
  
  <p>Thanks in advance
  Tobias</p>
  
  <p>UPDATE:</p>
  
  <p>Here is the java script code. The data-val property is set correctly to false. it seems that validation does not care of this property. there is also the data-val-required attribute but there is a text i could not backup.</p>
  
  <pre><code>$(function () {
                  $("#MyCheckbox")
                      .change(function () {
                          if (this.checked) {
                              $("#divWithChildProperties [data-val]").attr("data-val", true);
                              $("#divWithChildProperties ").show();
                          }
                          else {
                              $("#divWithChildProperties [data-val]").attr("data-val", false);
                              $("#divWithChildProperties ").hide();
                          }
                      })
              });
  </code></pre>