Reply To: Filled TextInput

PennController for IBEX Forums Support Filled TextInput Reply To: Filled TextInput

#6750
Jeremy
Keymaster

Hi Kathy,

Remember that the script is read and executed in a straightforward top-down fashion by PennController, and it will only pause on wait commands. So in your code above, all the elements are printed onto the page and then PennController stays on the Button element’s wait command until your participant clicks it. Once the button is clicked, all the test commands below are read and executed in a split second, and the next wait command that PennController reads is the TextInput’s wait command: if your participant did not press Enter while typing in the input box, they will have to press Enter while typing in that box so that PennController can continue reading the rest of the code. Then it will move on and read the next wait command, the one called on the “sex” DropDown element, and your participant will need to select an option from that list if they haven’t done so yet. Then the next wait command, and so on. (The last print command on the Button element will have no effect practically speaking, because the script will move on to the next trial immediately after it)

I don’t think this is what you want. What you want is for PennController to read everything, stay on the Button element’s wait command and only validate it if some conditions are met, but stay on it if those conditions are not met. You do that by inserting test commands inside the wait command, just like I illustrated above.

Regarding the restriction to numerical values, you simply replace the regular expression in your test with one that tests for numbers only, eg /^\d+$/.

Regarding the disappearance of the error messages, this is something you’ll need to code yourself. DropDown elements have a callback command that you can use to execute commands whenever an option is selected. So if you give unique names to your error messages, you could use callback on each of your DropDown elements to remove the corresponding error Text element. There is no callback command on the TextInput element that can detect keypresses, so you’d have to find a workaround. One option would be to use callback on a Key element to detect any keypress (including outside the input box) and remove the error message: it would overgenerate but it wouldn’t be too bad.

Here is a link to a project where I rearranged your code along those lines: https://farm.pcibex.net/r/SsqEZD/

Let me know if you have any questions

Jeremy