Hi! I’d like to validate my text areas so they don’t get submitted if they are empty (currently doing that by marking them as required), but I also need to validate that the user inputs at least 10 words or something like that.
How could I achieve this?
Thanks!
You need to add a filter to validate the value of your field. The documentation is here http://www.advancedcustomfields.com/resources/acf-validate_value/.
Something like this:
add_filter('acf/validate_value/name=your_field_name', 'my_validate_function', 10, 4);
function my_validate_function($valid, $value, $field, $input) {
$words = explode(' ', $value);
if (count($words) < 10) {
$valid = 'Please enter at least 10 words!';
}
}