Adding maximum word count in Gravity Forms

I love Gravity Forms, it’s one of my go-to plugins for all WordPress installs. Last week a client gave me the form fields for a new form and some of them needed a word counter to limit words to 300 in textareas. I found two possible solutions for adding maximum word count in Gravity Forms after a bit of searching, but neither worked for me (not being a programmer, I didn’t know how to fix them). But my programmer friends at CodeGeek stepped in and came up with this solution.

Here’s the Javascript which is saved in /themes/mytheme/js/ (it could also be put in an HTML block within the form itself, but we may want to use it on several other forms so made it available site-wide):

Then in functions.php, call the script:

Then in the Gravity Form for fields that need the word count, add the class ‘els-word-count[300]’ in the Advanced tab for CSS Class Name. Change [300] as needed for the maximum words that can be added to that particular field.


  1. I am searching for a minimum wordcount for GF. Wondering if your script can do this? I am not a programmer also, but it looks like there is a minimum word count implemented?! Line 9-10. Is it possible to use something like ‘els-word-count[50,1000]’ to pass min and max word count?

  2. I would say ‘probably’ but unfortunately I’m not a programmer either. It seems like it should be reasonably easy to modify though.

  3. btw, the code wasn’t working for me on multi-page forms so I changed a few things to get it to work correctly for me.

    I changed line 1 from :
    jQuery(document).ready(function($) {

    jQuery(document).bind(‘gform_post_render’, function(){

    so it hooks into gravity forms after the form renders. Also, since this no longer localizes the ‘$’ for jQuery you must then simply find/replace all the ‘$’ with ‘jQuery’ and you are good to go. Thanks for the post though, I still can’t believe this isn’t included with gravity forms and they only have a character count.

  4. Hi Debbie, this script seems to be promising but it does not work for me in Gravity forms. Are you sure that it has to be called using els-word-count[300]?

    I can’t find this as a string in the code…Can you check?

  5. Well I can confirm that els-word-count[300] is correct per my programmer, but the scholarship form isn’t on the client’s site anymore, so… I’m sorry, I can’t check it out directly.

  6. Hi Debbie,

    Thank you very much for posting this, it works perfectly (note the reference to jquery.gravity_word_count.js but the file name above is jquery.gravity_wordcount.js) but once that was changed it’s brilliant.

    Apart from one issue. If you enter the text in the form with paragraphs or separate sentences, as soon as you reach the limit the box will reformat the text and take out all of the line breaks.

    Do you know how this can be prevented so that it retains the formatting?



Leave a Reply

Your email address will not be published. Required fields are marked *