PennController for IBEX › Forums › Support › obligatory TextInput
Tagged: obligatory TextInput
- This topic has 2 replies, 2 voices, and was last updated 5 years ago by
Koorosh.
-
AuthorPosts
-
August 14, 2019 at 3:14 pm #4080
Koorosh
ParticipantHi 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!
KooroshPennController( “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 5 years ago by
Jeremy. Reason: More of a support question than a tip
August 14, 2019 at 3:23 pm #4081Jeremy
KeymasterHi!
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
August 14, 2019 at 5:20 pm #4082Koorosh
ParticipantIt works well now!
Thanks for the magic 🙂
Koorosh
-
This topic was modified 5 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.