Validators depending oneditprepare

#1

With oneditprepare I switch the html form elements:

oneditprepare: function() {
  $("#node-input-ThresholdType").change(function() {
    if ($(this).val() === "fixed") {
      $(".form-row-ThresholdTypeFixed").show();
      $(".form-row-ThresholdTypeDynamic").hide();
    } else {
      $(".form-row-ThresholdTypeFixed").hide();
      $(".form-row-ThresholdTypeDynamic").show();
    }
  });

Depending on the shown elements I would like to validate / require different #node-inputfields. When setting the validator or required properties in defaults they are globally active.
How can I set these properties according to the change function?

0 Likes