Skip to main content
Known Participant
October 27, 2019
Answered

Set up a text entry box to not accept a null value

  • October 27, 2019
  • 3 replies
  • 2638 views

Hi

 

I'm using Captivate 2019, I want to set a text entry box to force a user to enter their name and if they omit this, then a message box to display stating that their name must be entered before they can continue. I have set up my text entry box and trxt caption box to display the message but I've been unable to get this to work.

 

I have seen a guide to how to do this but I think it is old and some of the advanced actions look different in my version. I did manage some of it in adding an advanced action of creating if v_name is equal to v_null and Show NameIncorrect. The guide then goes to adding an expression and this is where I get stuck. The example shows rdcmdGoToFrame = rdinfoCurrentFrame - 1. I can't see rdcmdGoToFrame or rdinfoCurrentFrame in the drop down lists. Can anyone advise me please?

 

Thanks in advance

Guy

    This topic has been closed for replies.
    Correct answer Lilybiri

    Have a look at this blog post, where I explain in detail exactly this use case:

    http://blog.lilybiri.com/where-is-null-in-cp2017

     

    No Javascript needed, just some simple advanced actions. All is based on comparing the variable associated with the TEB to an empty variable which I indicate as v_nullo. I refurbished an olde blog of 8 years ago for HTML output. That old post was still very well visited, hence....

    3 replies

    Lilybiri
    Legend
    October 27, 2019

    The blog post clearly has a conditional action with ELSE included. 

     

    This must be very confusing for a newbie,  because in this thread two proposed solutions are now mixed up.

     

    I understood that you wanted to use tje JS solution... My approach is different, as a diehard teacher I prefer to teach how to fish, in stead of offering a fish (copy/paste code without realy understanding it). It is up to you which approach you prefer, but both will need time...

    RodWard
    Community Expert
    Community Expert
    October 29, 2019

    I am personally VERY grateful for Stagprime offering his JavaScript solutions when able.  

     

    I like fish and chips.  Personally, I don't care HOW the fish was caught as long as it tastes good in batter.

    Stagprime2687219
    Legend
    October 29, 2019

    Thanks Rod,

    As I stated above - I also prefer that people learn and understand but how else do we motivate learning if not by exposing the learner to that which is possible?

    As they say -  "You don't know what you don't know."

    Stagprime2687219
    Legend
    October 27, 2019

    If you're interested in another approach to this - I offer a JavaScript option.

     

    1. Make a text entry box and delete the submit button that comes with it.

    2. Make a variable (in my example - I call it  yourName)

    3. Make sure that the text entry box is associated with the variable that you create.

    4. Make your own smart shape to act as a button by clicking the 'Use as Button' check box

    5. For the button onSuccess action - choose 'Execute JavaScript'

    6. Place the following code in the Script_Window

    7. In this example I have a box named 'error' that is hidden by default and have it show if the field is left blank.

     

    if (yourName=="") {
    cp.show("error");
    }

    else {
    cp.goToNextSlide();
    }

     

    In my example - you would just need to replace the  yourName  variable with your own.

    If you have any questions about this I would be happy to elaborate.

    Known Participant
    October 27, 2019

    Thank you Stagprime, I've never attempted anything with Javascript but I 'll give your suggestion a go and let you know how I get on. Thanks again.

    Stagprime2687219
    Legend
    October 27, 2019

    If you copy this - it may fail until you go back and delete the quotation marks and actually type them with the keyboard.

    Lilybiri
    LilybiriCorrect answer
    Legend
    October 27, 2019

    Have a look at this blog post, where I explain in detail exactly this use case:

    http://blog.lilybiri.com/where-is-null-in-cp2017

     

    No Javascript needed, just some simple advanced actions. All is based on comparing the variable associated with the TEB to an empty variable which I indicate as v_nullo. I refurbished an olde blog of 8 years ago for HTML output. That old post was still very well visited, hence....

    Known Participant
    October 27, 2019

    Thanks but I'm very new to all of this! I still don't understand what I need to do, I've attached an image of how far I got, could you possibly spell out what I need to add next?

    Stagprime2687219
    Legend
    October 27, 2019

    Are EntryData  and  Empty  the names of variables that you created?

    Or are you using the names you assigned  and choosing literal in the advanced action window?

     

    Did you assign the text entry box to use the EntryData variable?