Hello!
I'm using form_text_input items to ask a few questions at the beginning of an experiment. Is it possible to prevent participants from hitting enter and moving on if they haven't typed anything at all? Or would it be better to go another way instead of using this form?
Thanks!
Comments
Hi @sflu,
Yes, it is possible. the easiest way is to use the repeat_cycle tool.
Let's say you're using a form_text_input, like this one:
The subject's response is stored in the vaiable called
response. The form is in a sequence within a loop that contains only onr trial.All you need to do is to add a repeat_cycle object after your form (i.e., at the end of trial sequence in this case) and set it to repeat the trial is the subject's response is empty, which you can do like this:
Now, the trial will repeat until the subject actually enteres something.
Note that this method will work is the subject just presses ENTER in response to the question, but not if they respond with an empty space (space bar) and then press ENTER because in that case the response is not actually empt but contains a character, be it an empty space. If that is an issue, you can insert some Javascript code (if you plan to use OSWeb, otherwise you could also use Python if you prefer) to parse the response and test it against whatever condition you wish and set a new variable to something you can then use in the
repeat-cycleobject. For example, you could wrote code to test whether the response string contains anything else than emty spaces and if it does, set a variable you could callviolationto 1, and then use[violation != 1]as the condition in therepeat_cycle.Hope tis helps,
Fabrice.
Perfect, thank you very much!