Freeform Question Text Entry Character/word Minimum?

Is there a way to set the requirements of a text entry freeform question to a minimum number of characters or words? So say I want learners to write 100 characters or 50 words before they can submit for example.

I can see that I can force people to answer but this means a character must be entered. 

Any thoughts? Workarounds?

4 Replies
Matthew Bibby

Here is a script that'll count the number of characters in a variable:

var player = GetPlayer();
var str = player.GetVar("TextEntry");
var n = str.length;

You'll need two variables in Storyline for this to work. 

First, a text variable called TextEntry which is used by the text entry field.

Second, a number variable called TextEntryLength which will capture the number of characters stored in the variable.

Here is a demo.

Here is the source file.

You can then use the TextEntryLength value to trigger stuff. For example, you may have a trigger that says "Change the Next Button to Normal State when TextEntryLength changes if TextEntryLength is greater than 50" or whatever. 

One problem with this approach is that nothing will happen until the user clicks away from the text entry field as the variable isn't stored until then. Which is annoying. Here is one way that you can work around that limitation. 

Steve Gannon

Hi Michelle,

Attached is another example using JavaScript. Here, the user's text entry must be at least 100 characters long and include 50 words.

Remember that when using JavaScript, any variables you want to pass back and forth between Storyline and JavaScript must first be created in Storyline. Also, the file must be published in order for the JavaScript to run.