Text Validation with returns

Apr 15, 2014

Hey all, 

I'm trying to build a course that has some text validation.  We're trying to teach a coding language. 

Attached is an example of what I'm trying to do.

In a text input field I want them to type exactly this: 


var @cat

set @cat = "cat"


On text input box lose focus, the variable blockinput1 is set to whatever they've entered.

But, when I set a condition to show the 'correct block' layer once the blockinput1 variable changes and matches that text, it always shows as incorrect.

I'm assuming it's something to do with the returns within the condition.  If I put \r into the condition, it doesn't work.  Is there some other way to specify that a return is correct in a condition value?  



2 Replies
Sam Parsons

also, just a side note, this is not the final presentation of this material, just a POC.  Edit - 

So I've been investigating javascript as a solution, but I'm a pretty bad coder.  This is what I've tried to implement to test the variable by executing this code on the submit button for answer 1.  

var p = GetPlayer();

var textValidate = p.GetVar("BlockCode1")

if(textValidate !== "%%[" + String.fromCharCode(13) + "var @cat" + String.fromCharCode(13) + "set @cat = " + String.fromCharCode(34) + "cat" + String.fromCharCode(34) + String.fromCharCode(13) + "]%%"){





so, I have an test in the module to output the value of BlockCode1, and it doesn't change.  So this isn't working.  Any tips??

This discussion is closed. You can start a new discussion or contact Articulate Support.