Skip to main content
Participant
October 1, 2017
Answered

Conditional State Change with Text Box Entry

  • October 1, 2017
  • 1 reply
  • 271 views

Student enters name in text box, submits, and character changes state "Congratulation (student name)!" Problem is the state change happens if student submits without enter name in text box. how do I make state change conditional on student actually entering name? Thanks.

    This topic has been closed for replies.
    Correct answer RodWard

    What event are you using to execute the Action to change the state of the character image?  Is it using the On Success action of the Text Entry Box?  If so, that event will fire as soon as the Submit button of the TEB is clicked, and your state change will occur regardless of the value in the TEB. Even if you turn on Validation in the TEB properties, there is no option given to ensure at least one or more characters are entered.  There's no default way to check for NULL values with TEBs.  But there is a workaround that requires you to create a user variable and a Conditional Advanced Action.

    The way to achieve this validation is to remove the Submit button of the TEB (by deselecting Show Button in the Actions section of the TEB properties) and replace it with another button that executes a Conditional Advanced Action that first checks the value of the TEB's Associated Variable against the value of a User Variable (you create).  This user variable is NOT given a value.  It is effectively a variable with a value of NULL.

    So you set the IF statement of the Conditional Action up so that the Change State action will ONLY be performed if the value of the TEB's Associated Variable CONTAINS something.  You achieve this by setting the condition to compare the TEB's associated variable with the NULL variable using the CONTAINS operand.

    It's not good practice to set an interaction up so that it will only work if the user does something correctly but then NOT tell them what happened if they don't perform the task correctly.  So, if you want to make your TEB interaction even better, you could create another state for the Character image that will be used to warn the learner that they haven't entered anything in the TEB so that this state can be shown as a kind of error message. So that if the learner tries to execute the TEB without entering a value, they are shown the error message character state which informs them they must enter their name.

    So, then if the user enters no value and clicks the replacement Submit button, the decision block will compare the two variables and find that the TEB's associated variable does indeed contain the same NULL value as your user variable and then change the character state to the error state. Since Conditional Actions don't automatically advance the timeline unless you set a Continue action, the user will remain on the slide with the TEB in this instance and then they can try again.

    1 reply

    RodWard
    Community Expert
    RodWardCommunity ExpertCorrect answer
    Community Expert
    October 1, 2017

    What event are you using to execute the Action to change the state of the character image?  Is it using the On Success action of the Text Entry Box?  If so, that event will fire as soon as the Submit button of the TEB is clicked, and your state change will occur regardless of the value in the TEB. Even if you turn on Validation in the TEB properties, there is no option given to ensure at least one or more characters are entered.  There's no default way to check for NULL values with TEBs.  But there is a workaround that requires you to create a user variable and a Conditional Advanced Action.

    The way to achieve this validation is to remove the Submit button of the TEB (by deselecting Show Button in the Actions section of the TEB properties) and replace it with another button that executes a Conditional Advanced Action that first checks the value of the TEB's Associated Variable against the value of a User Variable (you create).  This user variable is NOT given a value.  It is effectively a variable with a value of NULL.

    So you set the IF statement of the Conditional Action up so that the Change State action will ONLY be performed if the value of the TEB's Associated Variable CONTAINS something.  You achieve this by setting the condition to compare the TEB's associated variable with the NULL variable using the CONTAINS operand.

    It's not good practice to set an interaction up so that it will only work if the user does something correctly but then NOT tell them what happened if they don't perform the task correctly.  So, if you want to make your TEB interaction even better, you could create another state for the Character image that will be used to warn the learner that they haven't entered anything in the TEB so that this state can be shown as a kind of error message. So that if the learner tries to execute the TEB without entering a value, they are shown the error message character state which informs them they must enter their name.

    So, then if the user enters no value and clicks the replacement Submit button, the decision block will compare the two variables and find that the TEB's associated variable does indeed contain the same NULL value as your user variable and then change the character state to the error state. Since Conditional Actions don't automatically advance the timeline unless you set a Continue action, the user will remain on the slide with the TEB in this instance and then they can try again.

    Participant
    October 2, 2017

    Ok. I'll give that a try. Thanks!

    Lilybiri
    Legend
    October 2, 2017

    Description of the work flow with the empty variable (but since it is an old post, without states):

    Where is Null? - Captivate blog