Error in Validate Field with ACF plugin in Wordpress
I have the following problem when I am validating a field with the Advanced Custom Fields plugin in wordpress. What happens is that the field is validated correctly but the error appears on a new page instead of going out on the same page above the field to which I am validating. The code to validate is the following:
function validate_fields_contact()
{
add_filter('acf/validate_value/name=phone_contact', 'validate_phone_number', 10, 4);
}
function validate_phone_number($valid, $value, $field, $input)
{
if (!$valid) {
return $valid;
}
if(!preg_match("/^\+XX(\s|\d){8,12}$/", $value)) {
return __('Incorrect Format.');
}
return true;
}
It should be like that:
This is what happens
Topic advanced-custom-fields 500-internal-error validation Wordpress
Category Web