Constraint an integer field to 5 digits

You'll want to use the following syntax in your XLSForm. I suggest also added a hint and/or a constraint_message to tell the user why their answer may be rejected.

+------+------------+------------+----------+------------+-----------------------+--------------------------------------------------------+
| type |    name    |   label    | required | appearance |      constraint       |                  constraint_message                    |
+------+------------+------------+----------+------------+-----------------------+--------------------------------------------------------+
| text | incidencia | incidencia | yes      | numbers    | regex(.,'^[0-5]{5}$') | Must only contain numbers 0-5 and be exactly 5 digits. |
+------+------------+------------+----------+------------+-----------------------+--------------------------------------------------------+

For some additional related information see these posts:
Set Limit on Integer and Phone number and string length

1 Like