Forum Discussion

AliceBingham's avatar
AliceBingham
Community Member
2 years ago

Text entry containing a certain word - Trigger

Hi there, 

I would like to trigger a slide to lightbox in Storyline when a text entry box contains a certain word, or certain words. I'm struggling to do this with Javascript and conditions, can anybody suggest how I may get this working please? 

Many thanks

  • Hi Alice! It sounds like an interesting project! I'm not a JavaScript expert, but I did find this other discussion about something similar. I thought I'd share in case that ends up working for you. 

  • Hello everyone! I am trying to have a layer display if the text entry field contains certain words. I just want the user's answer to contain any of my chosen words but the order does not matter. Any advice?

    • JoseTansengco's avatar
      JoseTansengco
      Staff

      Hello Kelsey, 

      Looks like a Freeform Text Entry question is what you need! Using this slide, you'll be able to specify all of the correct words that a learner can enter to trigger a correct response.

      Note that this will only work for one word, so if you need more than one word to show a layer, you can just design a custom slide that makes use of multiple text entry inputs. I've attached a sample so you can see an example of a slide that makes use of multiple inputs to show a correct layer. 

  • I've got a similar question, but in this interaction I want the learner to be able to create an ID for a new client that does *NOT* contain spaces or special characters. Is there a way to create a trigger for that?

    • StevenBenassi's avatar
      StevenBenassi
      Staff

      Hi Holly!

      It sounds like you were interested in adding filters to text entry fields that would detect if the text has a space or special character.

      I see that you've opened a support case and connected with my teammate Dexter. Great move! It looks like Dexter replied to you sharing some feedback on how this would only be achievable through some custom Javascript coding.

      I would defer this question to our knowledgeable community members who may be able to share some insight or suggestions!

    • JohnCooper-be3c's avatar
      JohnCooper-be3c
      Community Member

      HI Holly

      Many thanks for your question - I am in the process of writing some short training modules on how to use JavaScript in Storyline for my website - I was just writing the section on "Why do we need JavaScript?" - and one reason is to manipulate strings and I was looking for a short example of where this might be useful... and then I spotted your question - perfect!

      So I quickly dashed out a quick demo - which you can find here...

      https://demo15.profilelearning.com

      If this is the code you are looking for, I will tidy it up and publish the JavaScript code here.

  • I should perhaps explain that since the JavaScript can recognise that the input text has spaces and/or special characters in it - it could just be used to output an error message explaining the user ID cannot contain these characters :)