oTree invalid form warning

190 views
Skip to first unread message

Noelito

unread,
May 10, 2021, 8:36:28 AM5/10/21
to oTree help & discussion
Hey everyone

We're currently programming a questionnaire, in which we use standard oTree forms definded in the player's class, as well as raw html forms directly programmed in the html class.

We discovered, that oTree form fields are automatically validated and generate an "error message" when the input is not correct and the user tries to  click the "Next" button. (See attachement: "Bitte geben Sie eine Nummer ein" - white text on purple backround at the field, where the error occured).


This does not happen with raw html fields. We managed to solve the problem by doing a custom validity check using javascript so that the user is alerted, if there's an invalid input in the custom html fields and the user tries to click the "Next" button. (See attachement: standard javascript alert).

We would like to match our alert with the alert of the oTree forms, but we couldn't find the source code for the oTree alerts. Is it possible to share the code?

Thanks in advance!
Noel
oTree-error.PNG
custom-error.PNG

Chris @ oTree

unread,
May 10, 2021, 8:45:17 AM5/10/21
to oTree help & discussion
To see the source code for the page, just right-click and view source, or press Ctrl+U. That dialog is displayed by the browser, not oTree. it probably comes from the 'required' attribute on the <input>.

Noelito

unread,
May 10, 2021, 10:14:19 AM5/10/21
to oTree help & discussion
Hey Chris

Id was the 'required' field, i could solve the problem by dynamically adjusting the required attribute, thank you!
Reply all
Reply to author
Forward
0 new messages