Turning on - but not shooting - RequiredValidator using jQuery / javascript

I have a form with maybe 10 fields. One of these fields is a checkbox, it is not checked by default, and the number of fields in the form is allowed only + if this field is checked. I successfully learned how to call ValidatorEnable (requiredFieldValidator, true) to handle this (I checked a lot of StackOverflow questions on this).

 function toggleStatus() {
          if ($('#ctl00_main_chkContactMe').is(':checked')) {
              $('#elementsToOperateOn :input').removeAttr('disabled');
              $('#elementsToOperateOn label').removeClass('off');
              ValidatorEnable($("[id$=RequiredFieldValidator1]")[0], true);
              ValidatorEnable($("[id$=RequiredFieldValidator2]")[0], true);
          } else {
              $('#elementsToOperateOn :input').attr('disabled', true);
              $('#elementsToOperateOn label').addClass('off');
              ValidatorEnable($("[id$=RequiredFieldValidator1]")[0], false);
              ValidatorEnable($("[id$=RequiredFieldValidator2]")[0], false);
          }
      }

, . , " ". , -, . Validator, , : " , , - "?

+5
3

:

var myValidator = document.getElementById('<%=myValidator.ClientID %>');
ValidatorEnable(myValidator, true);
myValidator.isvalid = true;
ValidatorUpdateDisplay(myValidator);

, .

:

function myValidatorEnabler(validator, enable) {   
    validator.enabled = enable;
    ValidatorUpdateDisplay(validator);
}
+10

. ( ). , , .

0

All Articles