I try to limit the field to two things:
1. can only write letters without numbers
2. can only enter characters in English and not in other languages.
how do I do it?
I would be very happy to get help.
Thanks!
https://www.advancedcustomfields.com/resources/acf-validate_value/
add_filter('acf/validate_value/name=your-field-name', 'allow_only_letters', 20, 3);
function allow_only_letters($valid, $value, $field, $input) {
if (!$valid) {
return $valid;
}
if (preg_match('/[^a-z]/i', $value)) {
return 'enter only letters';
}
return $valid;
}
I entered all this code and changed only:
'acf/validate_value/name=XXX'
When I enter data in the frontend, the wordpress crashes.
What’s the solution? And am I doing it right?
my error
add_filter('acf/validate_value/name=your-field-name', 'allow_only_letters', 20, 4);
Thanks!
I want to enable to add a space between the letters.
how do I do it?
Thank you!!
if (preg_match('/[^ a-z]/i', $value)) {