# Minimum Message Length in Fluent Forms

> Requires the message field of Fluent Forms to contain at least a few words, so you get enough detail to answer and fewer junk submissions.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: fluent-forms, validation, textarea
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/fluentforms-message-min-length/

## Code

```php
$wpide_ff_words_field = 'message';
$wpide_ff_min_words   = 5;

add_filter( 'fluentform/validation_errors', function ( $errors, $data ) use ( $wpide_ff_words_field, $wpide_ff_min_words ) {
    if ( ! isset( $data[ $wpide_ff_words_field ] ) || ! is_string( $data[ $wpide_ff_words_field ] ) || '' === trim( $data[ $wpide_ff_words_field ] ) ) {
        return $errors;
    }

    if ( preg_match_all( '/[\p{L}\p{N}\']+/u', wp_strip_all_tags( $data[ $wpide_ff_words_field ] ) ) < $wpide_ff_min_words ) {
        $errors[ $wpide_ff_words_field ] = array( sprintf( 'Please write at least %d words so we can help.', $wpide_ff_min_words ) );
    }

    return $errors;
}, 10, 2 );
```

## Notes

Change the field name and number of words at the top.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Minimum Message Length in Fluent Forms" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
