obligatory TextInput

PennController for IBEX Forums Support obligatory TextInput

This topic contains 2 replies, has 2 voices, and was last updated by Avatar Koorosh 1 month, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4080
    Avatar
    Koorosh
    Participant

    Hi Jeremy,

    I know that some people have asked a similar question to the one that I’m going to ask 🙂 I have read them and tried to run the codes. However, my problem is still unsolved.

    I want to make my TextInput for the background information to be obligatory. But my codes do not allow the participants to move forward. I’m not even sure if I have done everything I need to make it an obligatory TextInput! I tried to run it with HTML file as well, but it didn’t work either. I have copied my codes below.

    I will be grateful if you help me learn what has gone wrong in my codes! Thanks!
    Koorosh

    PennController( “background” ,
    newHtml(“Background Information“)
    .settings.css(“font-size”, “25”)
    .print()
    ,
    newText(“Date of Birth: (MM/DD/YYYY) After entering your date of birth in the box below, press the Return/Enter key.”)
    .print()
    ,
    newTextInput(“background”)
    .print()
    .wait( getHtml(“background”).test.complete())
    );

    • This topic was modified 1 month, 1 week ago by Jeremy Jeremy. Reason: More of a support question than a tip
    #4081
    Jeremy
    Jeremy
    Keymaster

    Hi!

    The code you report mixes Html and TextInput elements, when I presume you’d rather use only one type of element. Html elements are used exclusively to embed the content of an Html file that you have uploaded to your project, and I doubt that you have an Html file named “Background Information.” The complete test checks all the fields with the class obligatory in the corresponding file have been completed. This is not the test to use in the code you report since there is no “Background Information” Html file to start with.

    What you want is a test on your TextInput element: you want to make sure it is not empty. To do so, you need to use the text test on your TextInput element (or, rather, its negation) like this:

    newText("Date of Birth: (MM/DD/YYYY) After entering your date of birth in the box below, press the Return/Enter key.")
      .print()
    ,
    newTextInput("background")
      .print()
      .wait( getTextInput("background").testNot.text("") )

    NB: in your case, because you want a date in a specific format, you could even test the text using a regular expression: getTextInput("background").test.text(/^\d{2}\/\d{2}\/\d{4}$/)

    Let me know if you have more questions

    Jeremy

    #4082
    Avatar
    Koorosh
    Participant

    It works well now!

    Thanks for the magic 🙂

    Koorosh

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.