4 Replies
Matthew Bibby

Yes, this can be done. The user can enter as much info as they want in the text field, but after the variable is saved (when they click away from the text entry field) you can run JS to trim the variable length.

var player = GetPlayer();
var text - player.GetVar("TextEntry");
text = text.splice(0,5);
player.SetVar("TextEntry", text);

This assumes that you have a variable in SL called TextEntry and that you only want to display the first five characters. You can play around with the numbers on line three to adjust the amount of text allowed.

Now, the problem with this solution is that the user might enter a whole heap of info before realising that most of it will be removed. This is due to an SL limitation where the variable isn't saved until after the user clicks away from the text entry field. 

There is another way to solve this (by building a custom text input field using HTML, CSS and JS and importing it into SL via a web object) that would allow us to validate the text as it's typed, but that can be a hassle to get working.

Jennifer Munro

Thanks Matthew, the javascript is very helpful. :)

In my current project, ideally I'd want to users to not be able to input more text than will be displayed.  This project will have 10 Storyline files with 24 activities spread across them.  The activities will all have a number of text input fields.  Do you think it would be feasible to go with the custom input text field method?  One of my concerns is to make sure that it is as easy and intuitive for the participants as possible as we are expecting some with low computer/tech skills and need to make sure that we minimise frustration and make it accessible.  Are you able to take on paid work to create the custom input field? Or can you recommend someone?

Kind regards