Regex for whole numbers, with limited range of values

1. What is the issue?
I'm trying to limit number entry to integers (whole numbers) between, and including, 1-16. I believe this should work: regex(.,'^[1-9]$|^[1][0-6]$') if used in the constraints for an type=integer. It does correctly limit entries to 1-16, but, in webforms it still allows for decimals, like 1.2 or 12.6.

2. What steps can we take to reproduce this issue?
see screenshot for (4) below.

3. What have you tried to fix the issue?
I've tested the regex and it should work per

4. Upload any forms or screenshots you can share publicly below.

Try this: regex(.,'^[0-9]+$') and . > 0 and . < 17.

What specifically are you referring to wrt 'webforms'? AFAIK, Enketo - ODK's web browser client - wont actually permit you to enter a decimal place for an integer question, so your original regex appears valid... :thinking:

Try previewing this, with Enketo, here:
integer_regex.xlsx (10.7 KB)

1 Like