Forum Discussion

francoismarais's avatar
francoismarais
Community Member
2 years ago

capital letter always

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
  • SandeepGadam's avatar
    SandeepGadam
    Community Member

    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!

  • There are some fonts that have only capital letters. You might  use one of them to format it.

  • Yes thanks Walt
    
    it is finally the solution that I had kept because it is the simplest to implement