Support

Account

Home Forums Front-end Issues acf_form with custom validation message Reply To: acf_form with custom validation message

  • ACF already does validation and you can validate one field against another field using those filters. Here’s an example

    
    add_filter('acf/validate_value/name=password2', 'my_validated_password_filter', 10, 4);
    function my_validated_password_filter($valid, $value, $field, $input) {
      if (!$valid) {
        return $valid;
      }
      // field key of the field you want to validate against
      $password_field = 'field_0123456789abc';
      if ($value != $_POST['acf'][$password_field]) {
        $valid = 'Does Not Match Password';
      }
      return $valid;
    }