Support

Account

Home Forums General Issues Disable adding and reducing numbers Reply To: Disable adding and reducing numbers

  • https://www.advancedcustomfields.com/resources/acf-validate_value/

    
    add_filter('acf/validate_value/name=your-field-name', 'validate_text_as_number', 20, 4);
    function validate_text_as_number($valid, $value, $field, $input) {
      if ($valid !== true) {
        return $valid;
      }
      if (preg_match('/[^0-9]/', $value) {
        $valid = 'enter only numbers';
      }
      return $valid;
    }