Data constraint regex to not allow pure number in a string field

Need help in creating the expression to limit values for a text field. I would like the app to not accept an input reponse that is pure numeric. For example, for a field for name of company, the following are acceptable:
123 Marketing Inc.
ABC-123 Company
ICT4D Solutions, Inc.

But the following are not :
989965223 2554

Many thanks in advance! :slight_smile:


If you have a constraint of regex(., '[A-Za-z]'), that will require the user enters at least one character. Try that and let us now how it goes!

Thank you so much, Yaw. There's an update to our requirement. Am not sure if anybody has an idea on how to implement this. We would like to the app to not allow a value with 4 or 5 digits in a string. For example, the following are acceptable:
123 Marketing Inc.
ABC-123 Company
ICT4D Solutions, Inc.
But the following are not:

Or, if there's a way to flag a data collector that the string entered contains numbers and that he/she may have entered data incorrectly.

Thank you in advance.

You can have a note with the following relevance: regex(., '[0-9]{4,5}') that warns someone that they've entered a 4 or 5 digit number.

You could also try a constraint that is the inverse: not(regex(., '[0-9]{4,5}')).

If you have other regex questions, is a great resource!


Hi Yaw,

This constraint is asking me to enter only one character in ODK collect. it is not taking more than 1 character.

please suggest any other regex for not to enter the numbers in string field.


i have find out the solution to restrict the string to characters only

using the regex in constraint column for text type of question but provide some length of string of characters e.g


you can change the number {1-250} for your own limit for length of string

Best wishes

If you just want to measure string length, you can also use the string-length() method. has more.

Hello everyone,

I hope you are good.

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 this post 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

Hi @Olimpia
please check the answer on your first post and try to not duplicate your questions :wink:

1 Like