Do not accept if the answer is zero "0"

I tried to use this code in constraints however it's not working properly in ODK Collect.

regex(., ‘^[^0$]’)

My goal is, if the user will input "0" on the text field, the app will not accept the answer.

Hope you can help me, thank you so much!

You could just use this constraint :


I suspect @mathieubossaert response is probably what you are trying to achieve, but just to be clear, a '0' cannot appear anywhere in the text? (eg "100" should be rejected?) Or what about leading/trailing spaces (eg should " 0 " be rejected?) etc. You may well need a regex to handle these edge cases.

1 Like

Wow, thank you!! Been stuck here for a while :slight_smile:

Hi! Only "0" will not be accepted for this question. Thank you for your help :smile: