Forum Discussion

ErinSadler's avatar
ErinSadler
Community Member
7 years ago

Text entry must contain

Hallo - I've been trying to find or think up a workaround for this but I can't! Can anybody help?

I have a text entry field that I want users to complete - they can write anything at all, but it must contain specific words (let's say, for example; "Specific Words"!).

I don't want them to be limited to writing 'Specific Words' (although they would still pass if they did) - I want to encourage them to write more, but be judged correctly if 'Specific Words' is included in the text.

Is there any way I could do this?

13 Replies

  • Steven,

    These lines won't work, because the second one changes what the first one did, so the lower case is never searched for.

    var n = str.search("drain");
    var n = str.search("Drain");

     

    The attempt with two separate variables probably works, but these lines change the SL variable to the upper case regardless of which one is found.

    player.SetVar("draincoolant", "Drain coolant");
    }else if(m >= 0){
    player.SetVar("draincoolant", "Drain coolant");
    }else{

    Try      var str = player.GetVar("draincoolant").toLowerCase(); if you want to ignore case. The problem is that the answer is changed to all lower case, which is only a problem if you come back at the end and reset the SL variable. In that case, I would use strOri to store the original value, then use str = strOri.toLowerCase(); Search str, and use strOri to write to SL.