Minimum length of paragraph field

By: Stephen Walker | Asked: 04/17/2023
ForumsCategory: Code SnippetsMinimum length of paragraph field
Stephen Walker asked 2 years ago
Using this snippet from the developer docs and added to my functions.php file, this is not working. The original snippet did not include the form_id, which I added to avoid conflicts. Two questions:
  • Should this work as is?
  • If the field has validation (max length) set in the UI, does it eliminate this functionality?
  add_filter('frm_validate_field_entry', 'check_min_length', 8, 3);
function check_min_length($errors, $posted_field, $posted_value){ if($values['form_id'] == 2){
if ( $posted_field->id == 10 && $posted_value != '' ){
$words = explode(' ', $posted_value);
$count = count($words);
if($count < 6) $errors['field'. $posted_field->id] = 'Please provide a more complete response. Your response must be six words or more.'; }
return $errors; }
}

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right