WordPress.org

Support

Support » Plugins and Hacks » Word Count Restriction

Word Count Restriction

Viewing 10 replies - 1 through 10 (of 10 total)
  • I’m also in a situation where I’d like to know if this is possible.

    I’m still using Contact Form 7 version 3.3.1 because it’s the latest compatible version with Contact Form 7 Textarea Wordcount, which is no longer in development.

    has this feature been added to the newer versions of Contact Form 7?

    IIRC, 3.3.1 CF7 only supported text box character limits, but nothing for text areas.

    Thanks!!

    I wished I had read your post before I upgraded the Contact Form 7 plugin 🙁

    I REALLY need get an answer on this and the Contact Form 7 Textarea Wordcount plugin broke my website when I activated it.

    I haven’t found an answer yet for wordcount restriction. Still looking.

    Justine

    what you can do is go grab 3.3.1 CF7, and just continue with that onward until they add wordcount support.

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

    You can limit it to characters with something like this below. Just add it to your theme’s functions.php and change the 400 to whatever you need.

    // Limit Contact Form 7's textarea/message field to 400 characters
    add_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 ( 400 < strlen( $_POST[$name] ) ) {
    		$result['valid'] = false;
    		$result['reason'][$name] = "You have exceeded the 400 character limit.";
    	}
    
    	return $result;
    }

    I actually need to limit the textarea for more than just one textarea. I have 3 and 2 of them are 250 and the last textarea needs to be 400. How would I do this?

    Thank You,
    Justine

    @jpretorious Hi Justine, did you find a solution? I would like to know it, too… 🙂

    @chaoti I was able to use Contact Form 7 Textarea Wordcount plugin up until this week when I accidently upgraded to the latest Contact Form 7. It was great for word count but didn’t restrict the word count. Still searching.

    According to the changelog the latest version supports this now.

    “Support the use of the maxlength attribute for textarea ([textarea] and [textarea*]).”

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

    Thanks I will look into it 🙂

    @mickeyroush @jpretorious That’s right and I use it, but it only works as a shortener. I described that here: maxlength-function only works as a shortener?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Word Count Restriction’ is closed to new replies.