capital letter always

Aug 30, 2023

Good morning

I would like to have students enter information but I would like this information to always appear in capital letters even if the person enters in lower case

I don't see an option in ST360

THANKS
4 Replies
Sandeep Gadam

Hi francois marais, I've created a sample SL file as per your requirements. Add an execute javascript trigger in SL as per your requirement (timeline starts/ends or when user clicks).

Code for ALL CAPS:
var player = GetPlayer();
var newVar = player.GetVar("TextEntry");
newVar = newVar.toUpperCase();
player.SetVar("TextEntry", newVar);

Code for Initial Caps:
function capitalizeFirstLetter(string) {
return string.replace(/\b\w/g, function(l){ return l.toUpperCase(); });
}

var player = GetPlayer();
var newVar = player.GetVar("TextEntry");
newVar = capitalizeFirstLetter(newVar);
player.SetVar("TextEntry", newVar);

Let me know ff you need any further help!