Max character length for text entry?
Aug 15, 2013
By
Jim Matheson
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.
30 Replies
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.
From my experience no name should exceed 16 characters. Capping the max length to a byte is desired.
I am using Storyline 1. I need to limit the number of characters allowed in a text entry field so that the resulting text doesn't change size. How do I do this?
Hi Carrie!
That's not currently possible using a built-in method in Storyline, but you can submit a feature request here.
You might also be interested in a similar discussion that took place in this older thread.
This post was removed by the author
You could add a trigger "Execute Javascript" when control loses focus and then use the .length command, eg.:
var player = GetPlayer()
if (player.GetVar("TextEntry").length > 20)
{
alert("To long")
}
Or you could simply use an Essay Question slide, which allows you to specify the maximum number of characters.
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. :)
There is soooo much discussion on this topic on the internet and feature requests have been submitted. Does anyone know if this issue was addressed and resolved in Storyline 3?
Thanks for checking in, Phillip. Storyline 3 doesn't limit characters in a text-entry field, but you can certainly use an Essay slide to impose a limit.
Hi, you can also use javascript to limit the max character length.
It would make sense to simply apply same character limit code for variable fields and for Essay to Text Entry, wouldn't it? Why would we even have to submit a request for that?
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?
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.
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.
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.)
Hi Steve,
Thank you so much for your effort. Based on your description, it sounds like this might be a viable solution. Unfortunately, my company is still stuck on Storyline 2 and it won't let me open the file for 360. Any chance you could send me the javascript code to limit the characters?
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);
------------------------------------------------------------
Thank you so much for the detailed code with comments. I find most JS code posted in these forums is unusable because there's no explanation of what's written so you can't adapt it. I'm going to try it out right now. Thanks again!
Works perfect! Thank you so much!
Glad that worked for you, John.
Hi Steve. I'm curious. Is there a similar command to:
var field4 = field4.substring(0, 24);
to limit the number of lines a text entry box can have?
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.
How I can do it
Hello Amany and welcome to E-Learning Heroes :)
What Alyssa shared was a Survey Question Essay Type. Check out this gif on how to add that in and edit the max characters:
Hope that helps :)
This discussion is closed. You can start a new discussion or contact Articulate Support.