Forum Discussion
Minimum Character Requirement on Text Entry
I'm trying to create a 50-character minimum on the text entry input fields for a scenario interaction. I've added JavaScript and additional triggers, but they are not doing what I need. Can someone with more JavaScript knowledge please help me troubleshoot this?
I created a JavaScript requiring a minimum of 50 characters:
var player = GetPlayer();
var text = player.GetVar("vanessahines");
if (text.length < 50) {
player.SetVar("ShowErrorV", true);
} else {
player.SetVar("ShowErrorV", false);
player.SetVar("JumpToNextSlideV", true);
}
If less than 50 characters are entered when the user clicks submit, it should show the layer "Error".
If 50 or more characters are entered, when the user clicks submit, it should jump to the next slide.
But nothing is happening when clicking Submit, no matter how many characters are entered.
I found nothing wrong with your script. I tested it in an identical setup, and it works just fine.
The only issue seems to be that your variable name 'vanessahines' in the script does not match the variable name in Storyline, which is "VanessaHines."
var text = player.GetVar("vanessahines"); // should be VanessaHines
- NedimCommunity Member
I found nothing wrong with your script. I tested it in an identical setup, and it works just fine.
The only issue seems to be that your variable name 'vanessahines' in the script does not match the variable name in Storyline, which is "VanessaHines."
var text = player.GetVar("vanessahines"); // should be VanessaHines
- HollyGroszko-4cCommunity Member
thank you so much! That is what was causing the issue!
- HollyGroszko-4cCommunity Member
I realized the original trigger was still on the submit button, I removed that but it did not solve the issue.