Text Field - only allow digits and a separator

267
4
07-18-2022 08:30 AM
KellyTaylor
New Contributor III

Hey all,

I'm trying to figure out how to allow only digits (0-9) and a separator (preferably commas) in a text field in Survey123. It would ideally also show up as a number pad even though it's a text field. I've previously set the appearance to numbers but this only allows for integers or decimals, aka no commas or spaces.

Thanks!

0 Kudos
4 Replies
ZacharySutherby
Esri Regular Contributor

Hello @KellyTaylor

You can use a regular expression in the constraint column to limit the input to only be numbers and commas. The regular expression would be regex(.,'^[0-9,]*$') which would go in the constraint column, and you can provide a constraint message as you see fit. 

If you would like to use the number pad you can also set the bind::type to Int and set the appearance to numbers. That way Survey123 will treat the question as an integer question but in reality it's being stored as text. 

 

Thank you,
Zach
KellyTaylor
New Contributor III

Hi Zach,

Thanks so much for your reply. Your solution is *almost* perfect for what I'm trying to do except that when appearance is set as numbers, there is no comma available on the number pad that displays.

Any thoughts on a workaround for that?

Thanks again!

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @KellyTaylor

If you switch the bind::type to decimal and keep the numbers appearance depending on your locale you will see a decimal or comma. If you are in a comma separated locale you will see a comma otherwise if you are in a decimal locale then you will see a decimal. That would be the closest in terms of an appearance that we would have. Otherwise if you keep the bind::type as integer or decimal with no appearance the default number pad on the OS will be used which may have a comma. 

Thank you,
Zach
0 Kudos
KellyTaylor
New Contributor III

Hmm, ok. It seems like I might have to shift directions and just make it a repeat rather than having the user use a separator. Thanks so much for your help!

0 Kudos