Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Word counter feature included on Open-Ended questions

Is it possible to include a "Word Counter" feature on an Open-Ended question?

As an extension to this, restrict the respondent from entering above the specified number of maximum words, or force the respondent to enter within a range.

asked Jul 10, 2019 by Paul Moon Platinum (101,255 points)

1 Answer

0 votes
It can be done, but it's not as arbitrary as a character count as the definition of what defines a "word" has some room for ambiguity.  Try this:

<span class="[% QuestionName() %]_wordcount"></span>

    updateWordCount('[% QuestionName() %]');

$(document).on('keyup', '#[% QuestionName() %]', function(){
    updateWordCount('[% QuestionName() %]');

function updateWordCount(questionName) {
    var matches = SSI_GetValue(questionName).match(/\S+/g);
    var count = matches ? matches.length : 0;
    $('.' + questionName + '_wordcount').text(count);
answered Jul 10, 2019 by Zachary Platinum Sawtooth Software, Inc. (214,675 points)
Thanks Zachary. Much appreciated.

I'll test your version out and report back to this post.

I just thought this would be a useful feature to many Sawtooth Software users as a standard feature under the Settings tab.

Stay tuned.
Character counter