A known deficiency with the current version of Survey123 Connect is that it does not evaluate constraints until form submission. Many users have the need or desire to have their surveys evaluate a regular expression constraint before proceeding to the next question or next page in their form (more on the problem here).
Below is a possible (although somewhat clunky) work-around. It uses 'note' type rows so that no new fields are required in the data schema.
type | name | label | appearance | required | required_message | calculation | constraint | constraint_message::default | constraint_message | relevant |
begin group | user_info | User Info | field-list | |||||||
text | name | Name | yes | Enter a valid name to proceed | ||||||
note | namecheck | namecheck | hidden | if(regex(${name}, '^[a-zA-Z]'), "OK", "") | ||||||
note | nameerrornote | Enter a valid name to proceed | ${name}!="" and ${namecheck}!="OK" | |||||||
range | age | Age | yes | ${namecheck}="OK" | ||||||
text | additionalnotes | Additional Notes | ${age}!="" | |||||||
end group |
There may be more elegant workarounds, so if you're aware of ways to make this more slick, please comment.
I think it's a solid workaround, similar to what we do for immediate feedback on some of our forms.
Edit to add: if there's a better way to accomplish this, I'd love to know, too!
My method to use emoji's has been working out well. It does not stop them though.
I'd make ${namecheck} a calculate. That way you can drop the "label" and "appearance". Less work is always a good thing.
Also, notes don't need "names", so you can delete "nameerrornote" from the name column entirely.
Otherwise ya, doing it line by line is the only way.
As @DougBrowning mentioned, emojis work well for visual feedback (would be amazing if that was a built-in behaviour). But in the end, do whatever works well for you.