Max character length for text entry?

I need to cap the max character lengths for some text entry fields but I do not see an option (or properties for that matter) that allow me to do that. The reason I ask is because I have some variables that are set for first and last names. Later in my project I have some captions that display those entries. However, the text shrinks when it is longer than the caption's size. I notice, too, that the captions do not resize at runtime. That only resize while you are editing the text in the Slide View. Is this a bug? I need the names to appear but I don't want them to reduce in size. 

26 Replies
Phil Mayor

Jim Matheson said:

I need to cap the max character lengths for some text entry fields but I do not see an option (or properties for that matter) that allow me to do that. The reason I ask is because I have some variables that are set for first and last names. Later in my project I have some captions that display those entries. However, the text shrinks when it is longer than the caption's size. I notice, too, that the captions do not resize at runtime. That only resize while you are editing the text in the Slide View. Is this a bug? I need the names to appear but I don't want them to reduce in size. 


There is an issue with variables shrinking the text, you could try stretching the textbox a bit to give more space.

I dont think limiting the number of characters on a name entry field is a good option, what about those users who have long names.

Christie Pollick

Thanks Karel and Steve for your input here in this older thread, as it may prove useful to others who come across this post looking for assistance on a similar topic. I did want to note for others who may not be aware, as Karel mentioned the use of JavaScript, we are unable to provide support to assist with JS coding. Here, however, is our JS Best Practices sheet. :)

David Breen

The only response I can find is "Please submit a feature request" which goes back to 4 years ago. I'm of the understanding that if you publish to AMP, your javascript commands will not work. Can anyone confirm that for me? I'm using SL360 and if it doesn't work on AMP I can't use JS.

Otherwise the second option I've found is create a Survey Essay Question and limit the character count to 1. Which works but then it won't let me duplicate my entry field. Says field cannot be copied.

Is there anyway to have more than one Survey Text Entry Field on the same slide?

Ashley Terwilliger

Hi David,

Javascript is not supported in the Articulate Mobile Player, but with Articulate 360 you may only need the AMP if you're looking to have content accessible offline on an iPad or Android device. Otherwise, you could use the responsive player that is built into the Storyline 360 HTML5 output.

As for limiting the character count, I'll leave that to the community who are much more versed in Javascript than I am. 

You can definitely add more than one text entry to slide, but on a survey/question slide that you're looking to track to an LMS - those are all set up for only one question/answer per slide. If you'd like to send the value of a variable to your LMS, you may want to use the steps here.

John DePauw

I'm having the same problem. I need multiple text entry fields on the same slide but with character limits. I'm open to Javascript solutions, but I wasn't able to get the one posted to work. Or if anyone has another solution for essentially having the users fill out a form in Storyline, saving the info to variables, then posting the variables on a nicely formatted sheet at the end.

Steve Gannon

Hi John,

The file attached may get you started. On the first slide, you're prompted to complete 5 text entry fields. On the second slide, the value of your entries is displayed.

As you type in an entry field, you can type as much as you like...your text will scroll to the left within the text entry box. On the second slide, an Execute Javascript trigger is used to truncate your entries to 25 characters. So although this demo won't stop you from typing at a certain character limit, the end results are truncated to a character count you determine in the Javascript.

Note that since this contains Javascript, you will need to publish it to see it working properly. (And if it still doesn't work, you may have to place your published output on a server.)

Steve Gannon

The code is between the dashed lines below (don't include the dashed lines). The "Field" variables beginning with uppercase "F" are the variables that would need to first be created in Storyline in order for this code to work. If I get a chance in the next day or two, I'll create a Storyline 2 version for you.

------------------------------------------------------------

//Open communication between Storyline and Javascript
var player = GetPlayer();

//Create variables in Javascript called field1, field 2...field5
//and assign these new variables to the equivalent variables
//we created in Storyline
var field1 = player.GetVar("Field1");
var field2 = player.GetVar("Field2");
var field3 = player.GetVar("Field3");
var field4 = player.GetVar("Field4");
var field5 = player.GetVar("Field5");

//Truncate the values to 25 characters using the substring method
//Note: the index for the first character is zero, not 1
var field1 = field1.substring(0, 24);
var field2 = field2.substring(0, 24);
var field3 = field3.substring(0, 24);
var field4 = field4.substring(0, 24);
var field5 = field5.substring(0, 24);

//Assign our Storyline variables to these updated Javascript variables
player.SetVar("Field1", field1);
player.SetVar("Field2", field2);
player.SetVar("Field3", field3);
player.SetVar("Field4", field4);
player.SetVar("Field5", field5);

 

------------------------------------------------------------

Steve Gannon

Hi John,

I'm not aware of a comparable "subline" method. It's possible to do what you're interested in but it's a bit more involved. One way is to search for "return" characters (coded as "\r" for a hard return and "\n" for soft returns) and parse out individual lines that way. Those lines could be inserted into an array and then you can determine how many elements (in this case, each element in the array would be a single line of text) to extract from the array.