Allowing only alphabetic letters in a text answer

Hello everyone,

I hope you are well and safe.

I am writing a survey in ODK Collect and for some text questions (e.g. individual's name) I would like to allow only letters to be entered. I have seen in a previous post on the forum that it was suggested to add regex(., '[A-Za-z]') to the constraint column. However, when doing this, the survey gets converted in xml fine but then does not allow me to enter an answer on the app. Do you know why this is happening?

Many thanks in advance for your help
Best,
Olimpia

Hi @Olimpia,

I think you missed an quantifier in the regexp, something like [A-Za-z]* if an empty string is allowed or [A-Za-z]+ if at least one letter is required
This resource is quite useful :

And this documentation page :
https://docs.getodk.org/form-regex/

Hi @mathieubossaert ,

Thank you for your reply, it was really helpful. [A-Za-z]+ works, however, if I want to write two separate names it does not allow me to do it. How can I had a constraint to be with a space if the user wants to add a space? I have seen online that you can do regex(.,'[A-Z][a-z]{1,50}{1}[A-Z][a-z]{1,50}’). However, this will enforce the space which is not what I want exactly.

Do you have any suggestions?

best,
Olimpia

[A-Za-z]+\s{0,1}[A-Za-z]*
should work : at least one letter followed or not by a space, followed or not by some letters

1 Like