WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Limit number of character in textarea (2 posts)

  1. Nivo
    Member
    Posted 3 years ago #

    Hi,

    I have added the following code in my fonctions.php theme file:

    a`dd_filter( 'wpcf7_validate_textarea', 'character_length_validation_filter', 11, 2 );
    add_filter( 'wpcf7_validate_textarea*', 'character_length_validation_filter', 11, 2 );

    function character_length_validation_filter( $result, $tag ) {
    $name = $tag['name'];

    if ( ! $result['valid'] )
    return $result;

    if ( 250 < strlen( $_POST[$name] ) ) {
    $result['valid'] = false;
    $result['reason'][$name] = Too long.";
    }

    return $result;
    }`

    Everything is working fine but when I exceed 250 character the error message that is showing on the form is just saying NULL. Can someone give me a hand on that please?

    Regards,

    Alex

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Nivo
    Member
    Posted 3 years ago #

    oops sorry! double post...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic