Support

Account

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

  • It should work on the front end as well as the back end.

    Check you acf_form setup. Are you calling acf_form_head(); before get_header(); and make sure that your theme is also calling wp_footer(); If something here is wrong it could be causing the JS to error.

    Another thing is that if you have the field marked as required then if it’s left blank you’ll get the standard ACF error message. If you want to completely override that remove the check at the top of the function that returns if the field is already not valid

    
    add_filter('acf/validate_value/name=password2', 'my_validated_password_filter', 10, 4);
    function my_validated_password_filter($valid, $value, $field, $input) {
      // 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;
    }