DevelopmentMarketingPress / NewsTips

Contact Form 7 Textarea Wordcount, by Ninthlink

By December 30, 2010 25 Comments

contact-form-7-text-area-word-count

When one of our clients asked that their site’s Contact form have a Max Word limit on a “Comments” textarea / “text area” field, and that Contact Form was using the nice Contact Form 7 WordPress plugin, the quickest way I knew to achieve this was to create a plugin to add a bit of extra functionality to how CF7 handles Text areas. 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 Text area, and then on the front end, adds a simple jQuery script to limit input on that text field to the given number of words.

Like it? Download the plugin to use on your own site. Don’t like it, or have questions or comments or concerns? Please use the WordPress.org support forums.

Update for 2016 : after being dormant for 2 years and a whopping 35 version releases of Contact Form 7 since this was last updated, it is now updated to be compatible with the latest versions of Contact Form 7 and WordPress core, which as of this update are 4.4 and 4.4.2 respectively.

Alex Chousmith

Alex has been building with Ninthlink since '06, and a San Diegan since the turn of the century. A background of Mathematics – Computer Science / Interdisciplinary Computing & Arts from UCSD, plus Drupal / WordPress / jQuery / CSS3 / HTML5 / bass guitar / homebrew skill, powers him to get the job done, no matter what.

25 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!!)

  • Luis says:

    You have a update pay for this plugins

  • Alex Chousmith says:

    Hello all! This plugin has now been updated for Contact Form 7 v4.4 – please update or download the new version from https://wordpress.org/plugins/contact-form-7-textarea-wordcount/ . Any future comments should be posted under WordPress.org support forms https://wordpress.org/support/plugin/contact-form-7 as we are now closing comments on this old blog post here. Thank you!!