Contact Form 7 Textarea Wordcount, by Ninthlink

When one of our clients asked that their site’s Contact form (which I was building via the most excellent Contact Form 7 WordPress plugin) have a Max Word limit on the Comments textarea field, the quickest way I knew to achieve this was to create a plugin to add a bit more functionality to how CF7 handles Textarea’s. Thanks to WordPress & Contact Form 7’s use of hooks and filters, the plugin simply adds an extra text field in the back end, allowing admins to specify a max word count on any Textarea, and then on the front end, adds some jQuery magic to limit that text field to the given number of words.

Like it? Download the plugin to use on your own site. And please add any questions/comments/suggestions/criticisms below, or to the official page on WordPress.org!

Join the discussion 23 Comments

  • Craig says:

    Cool!

  • Olga says:

    Plugin count not only words but also spaces… (((

  • Russell says:

    maybe there should be a words box and a character box?

  • András Király says:

    When reached the given limit of words the complete javascript suddenly appears in the textarea (box) making it useless. I’ve tested this on various computers and in various browsers, so i think it is related to WordPress and plugins.

    And yes, ‘space’ is not a word, it is absolutely crazy to count them.

  • i see an issue where a commenter could enter text like “this         is a lot of spaces in between” and the extra spacing would throw off the word count, but i cannot replicate the “When reached the given limit of words the complete javascript suddenly appears in the textarea (box) making it useless”

    the “word count” is done by using the JS “split” method to split the text in the textarea apart for each ” ” (space) and chop off after 10 space’d separations

  • Is it possible to adjust this plugin to count characters instead of words? can you explain it if so ? Thanks in advance.

  • fresh shop says:

    Hi,
    how can I add an operation (multiplication) so it calculates the wordcount times X (1.5 for example) Don’t know much php but suppose “.$multiplication.” will have to be used.
    Thanks

  • Alex Chousmith says:

    Paulo – it was a pretty quick hack for me to repurpose the existing “maxlength” field in CF7 for the purpose of max Words. i am not quite sure as of yet how to add another option in there to allow users to specify counting Characters rather than Words.

    what you could do though is to just copy the wpcf7wc.js file to your active WP theme, and then in your theme’s functions.php file, do

    wp_deregister_script(‘wpcf7wc’);
    wp_enqueue_script(…

    and use your own version of the script. then you could modify the JS to simply count characters rather than words?

  • Amanda Gillespie says:

    This plugin breaks my form if I am also trying to use Watermark text in the textarea. Any ideas on how to fix that, because I’d love to use this but I’d choose my watermark text over the character count…

  • Fireball says:

    Rather than have to count words, count characters?

  • Gman says:

    Thanks for creating this plugin and sharing it with the community. I’m also having the error ‘script appears in the text area box after word count has been reached’. Is there any way I can aid you in troubleshooting this issue, as you cannot replicate it? Or maybe you’ve been able to duplicate the issue since your previous reply?

  • Tim says:

    Works like a champ! Thanks so much…

  • joey says:

    Just what i have been looking for.

    THANKS!!!

  • joey says:

    since the last contact form 7 update, this plugin is causing my whole WP installation to stop working, I disabled this plugin,and everything is working again.

  • Alex Chousmith says:

    thanks for the heads up, Joey. i will check it out with the latest versions of WP + CF7 & get this fixed up asap

  • ndree says:

    Hi Alex, nice job on the hack , but i am getting the javascript also after reaching 400 words for example. any update will be nice. Thanks.

  • Mike Lyon says:

    Seems to work flawlessly for me! Excellent! Wish I could limit to characters as another option! Thanks!

  • Yardena says:

    Does this plugin work with the latest wordpress version?

  • Scott says:

    Just wanted to say that something was again changed in the recent version of Contact Form 7. Updated, and my whole site was down with a 500 error. Renamed this plugin’s folder and brought it back up.

    Now, i’m off to find an older version of Contact form 7…

  • Ele says:

    Hi,
    this little plugin ” Contact Form 7 Textarea Wordcount” is so great (better it was…..)
    Can I (we) hope for an update to use it in CF 3.3.3??????????????????????????????????????

    Hopefully Peter

  • Uddhava says:

    The Wordcount plugin stopped working after the latest update of Contact Form 7. Just a reminder ;-)

  • Alex Chousmith says:

    Thanks for all the great feedback, all. We will be working to update the CF7 Textarea Wordcount plugin for the latest versions of Contact Form 7, over the next couple weeks.

  • Mike Lyon says:

    I’ve reverted to Contact Form 7 ver 3.4.2

    Nudging you that this plugin needs to be updated to current version of CF7 as it otherwise crashes WordPress! Yikes!! Been months! Have a heart! (gentle reminder, and THANKS!!)

Leave a Reply