Forum Discussion
Remove/Ignore spaces at the end of multiple text entry fields - Javascript question
Hi, thanks for sharing your code. I was trying to make it work in one of my projects, I didn't at the begin but at the end with some modifications it did.
What I did to make it work: for the first slide I used the following code (the first slide with text entry):
var p = GetPlayer();
var p = GetPlayer();
var textentry = p.GetVar("TextEntry");
var newTextentry = textentry.replace(/^\s+|\s+$/g, '');
p.SetVar("TextEntry",newTextentry);
Then for the rest I used this one:
var p = GetPlayer();
for(var i = 1; i < Y; i++) {
var textentry = p.GetVar("TextEntry" + i);
var newTextentry = textentry.replace(/^\s+|\s+$/g, '');
p.SetVar("TextEntry" + i,newTextentry);
}
-Y- should be the last text entry you have plus 1.
Make sure your triguer is before the submit interaction trigger.