Share Twitter Facebook LinkedIn Google+

Word Count in Articulate Storyline – JavaScript Makes it Count

Written By

Word Count in Articulate Storyline - JavaScript Makes it Count

In an eLearning course, you can let your learners complete a short “essay type” activity at the end of the training, and let them know the number of words they’ve entered in the text field.

For example, if the learner has to write approx. 150 words for a particular answer and falls short of the required word count, there will a prompt asking the learner to continue writing.

Wondering how to do this? It can be done in Articulate Storyline, through the help of JavaScript. Let’s see the steps it entails.


In a new slide, insert a Data Entry field to enter text.

(Insert a Controls a Data Entry a Text entry field)

Insert a data entry field Step1

Enlarge the text entry field to type the text in a paragraph format. If the learner is required to enter a minimum or maximum number of words, a word counter can help meet this requirement.

Enlarge the entry field to type the text Step 1

Step2: Now we have to create 2 variables; Wordcount, a text variable and Counted, a numeric variable.

Create word count and numeric variable Step2

Step3: Use the variables to create a trigger – Execute JavaScript.

Use the variables to create the trigger Step 3

Click Add/Edit JavaScript and write the script given below by calling the created variables in JavaScript.

var player = GetPlayer();

var content = player.GetVar(“Wordcount”);

var matches = content.match(/\S+\s*/g);

var numWords = matches !== null ? matches.length : 0;


Click add or edit java script Step 3

Step 4: Place your cursor in the Text Entry field and type your text. You can also paste text into the text entry field. When the user clicks the Total Words button, the Execute JavaScript trigger will be processed and will automatically count the number of words typed.

Place your cursor in the text entry field Step 4

Execute java script trigger Step 4

This is an easy way to let your learner know the number of words he has entered.

In my next, blog we will see how to count the characters in Articulate Storyline. See you soon!

View eBook on Articulate Storyline for Building E-learning Courses


Subscribe to Our Blogs

Get CommLab's latest eLearning articles straight to your inbox. Enter your email address below:

eLearning Learning