Support

Account

Home Forums Add-ons Repeater Field Validation for Date Range Reply To: Validation for Date Range

  • Yes, it is

    
    add_filter('acf/validate_value/name=end_date', 'validate_end_date_func', 10, 4);
    function validate_end_date_func($valid, $value, $field, $input) {
      if (!$valid) {
        return $valid;
      }
      $repeater_key = 'field_56faad2a333ab';
      $start_key = 'field_56fab49fd51ce';
      $end_key = 'field_56fab4d1d51d0';
      // extract row from input
      $row = preg_replace('/^\s*acf\[[^\]]+\]\[([^\]]+)\].*$/', '\1', $input);
      $start_value = $_POST['acf'][$repeater_key][$row][$start_key];
      $end_value = $value;
      if ($end_value <= $start_value) {
       $valid = 'end value must be greater than start value';
      }
      return $valid
    }