Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nastiarocks/24911024cbdf6dadc29bef3986376326 to your computer and use it in GitHub Desktop.
Save nastiarocks/24911024cbdf6dadc29bef3986376326 to your computer and use it in GitHub Desktop.
Created by WPMU DEV Developers. Replace the textarea-1 with your ID field. Edit line #6 to set minimum limit of characters
<?php
add_filter( 'forminator_custom_form_submit_errors', function( $submit_errors, $form_id, $field_data_array ){
$field_id = 'textarea-1';
foreach ( $field_data_array as $key => $field ) {
if ( $field_id === $field['name'] ) {
if ( 15 > strlen( $field['value'] ) ) {
$submit_errors[]['textarea-1'] = 'You need to insert at least 15 characters in the textarea';
$_POST['forminator-textarea-invalid-length'] = true;
}
}
}
return $submit_errors;
}, 20, 3 );
add_filter( 'forminator_custom_form_invalid_form_message', function( $invalid_form_message, $form_id ){
if ( isset( $_POST['forminator-textarea-invalid-length'] ) && $_POST['forminator-textarea-invalid-length'] ) {
$invalid_form_message = 'You need to insert at least 15 characters in the textarea';
}
return $invalid_form_message;
}, 20 ,3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment