I have a survey form created in Survey123 Connect which has style settings of theme-grid pages. I have several fields with constraints, most of which work as expected. However I have one field (TimeOnSite) where neither the constraint message (default of invalid, or custom wording), nor the red box that is expected to occur appear. However, the survey form does 'push' the user back to the form page containing the incorrect field for correction when trying to submit an incorrect entry (but with no guidance on the error or indication exactly which field as the red square doesn't appear). The only instance that results in the correct constraint message and red box appearing is if the time is changed to a future time (in combination with the current date), not if just the date is set to a future date and the time is left unedited (i.e., using current default time). If I change both the date and time to a point in the future, the constraint message and box do not appear. If I change it just the time to a time beyond now (keeping the date as today), the constraint message and box do appear.
In contrast, the TimeOffSite field (details below) does work as expected, including both constraint message and red box.
The field details are as follows:
type | name | constraint | constraint_message | default | relevant |
dateTime | TimeOnSite | .<=now() | Cannot be in the future | now() | ${SurveyType}!='AdHoc' |
dateTime | TimeOffSite | (.<=now()) and (.>=${TimeOnSite}) | Cannot be in the future or before the start date and time | now() | string-length(${TimeOnSite})>0 and ${SurveyPossible}='yes' |
Does anyone have any insights as to why the red box and constraint may not be appearing for the TimeOnSite field? I have also tried setting the constraint formula as (.<=now()) and (.<=today()) but this has the same result.
Many thanks,
Rob
Try a space between . and < also . and >. At times these get interpreted as HTML and get messed up. I cant find the old post on this but give it a shot. Not sure if it was fixed yet. Just a shot in the dark.
Thanks Doug. I've just tried your suggestion but unfortunately it doesn't resolve the issue.
It appears to be understanding the constraint expression correctly as it is forcing the user back to the page containing that field to correct it. However the display of the constraint message and red box is seemingly linked to particular parts of the field (time rather than date).