# How can I make a limit to the ‘integer’ data type?

**URL:** <https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054>\
**Category:** Support\
**Tags:** odk-xlsform\
**Created:** [October 31, 2019, 3:10am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054 "2019-10-31T03:10:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TanzilHuda](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tanzilhuda/32/9152_2.png) [@TanzilHuda](https://forum.getodk.org/u/TanzilHuda)\
**Post date:** [October 31, 2019, 3:10am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/1 "2019-10-31T03:10:20Z")

</div>

My limit will be 01-99. No one can enter ‘1’. The user has to input ‘01’. That means in the integer (Number) data types users must have to input always 2 digit numbers.

![2%20digit](https://getodk.b-cdn.net/uploads/default/original/2X/4/452272bdee0a2ed82e2d1967d47cd03bc6ca0f5b.png)

Thanks in Advanced

---

<div class="post-metadata">

**Author:** ![Grzesiek2010](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/grzesiek2010/32/2881_2.png) [@Grzesiek2010](https://forum.getodk.org/u/Grzesiek2010)\
**Post date:** [October 31, 2019, 7:23am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/2 "2019-10-31T07:23:49Z")

</div>

Hi @TanzilHuda

you need to use [regex](https://docs.opendatakit.org/form-regex/) something like just `0[1-9]|[1-9][0-9]` maybe?

---

<div class="post-metadata">

**Author:** ![TanzilHuda](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tanzilhuda/32/9152_2.png) [@TanzilHuda](https://forum.getodk.org/u/TanzilHuda)\
**Post date:** [October 31, 2019, 9:00am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/3 "2019-10-31T09:00:59Z")

</div>

Thanks, @Grzesiek2010, I have tried just like your suggestion. But it's not working. Would you show me the exact code?  
 ![regularexpre](https://getodk.b-cdn.net/uploads/default/original/2X/9/9572444aa127cb7d2b97228ce53107cdca5de4e0.png)

---

<div class="post-metadata">

**Author:** ![Grzesiek2010](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/grzesiek2010/32/2881_2.png) [@Grzesiek2010](https://forum.getodk.org/u/Grzesiek2010)\
**Post date:** [October 31, 2019, 9:54am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/4 "2019-10-31T09:54:30Z")

</div>

Hmmm I'm not an regex expert I just tested it using an online tool like [https://regexr.com/](https://regexr.com/) and it was fine.

---

<div class="post-metadata">

**Author:** ![TanzilHuda](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tanzilhuda/32/9152_2.png) [@TanzilHuda](https://forum.getodk.org/u/TanzilHuda)\
**Post date:** [October 31, 2019, 11:32am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/5 "2019-10-31T11:32:17Z")

</div>

It works on string data type. But not working on 'numeric' data type

---

<div class="post-metadata">

**Author:** ![Andrea\_Martin](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/andrea_martin/32/9078_2.png) [@Andrea\_Martin](https://forum.getodk.org/u/Andrea_Martin)\
**Post date:** [October 31, 2019, 2:58pm UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/6 "2019-10-31T14:58:31Z")

</div>

Hi @TanzilHuda

01 is technically not an integer, but a string.

I suggest you use the text data type, setting the constraint="regex(.,'^[0-9]{2}$')"  
You can also select appearance="numbers" to ensure the right keyboard is shown to the enumerators.

Reference: [https://docs.opendatakit.org/form-regex/#tips-on-using-regular-expressions](https://docs.opendatakit.org/form-regex/#tips-on-using-regular-expressions)

 ![56](https://getodk.b-cdn.net/uploads/default/original/2X/4/4e70ea21376c7971fea217001a521f9850cf1e57.png)

I hope this helps!

Best,  
Andrea

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [November 1, 2019, 2:54am UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/7 "2019-11-01T02:54:03Z")

</div>

> [@Andrea\_Martin](#):
>
> regex(.,'\[1\]{2}$')

Unfortunately, this permits "00", whereas the requirement was 01-99 [D'oh! 🙂] This seemingly minor nit makes a solution rather messy...

Have a play around (eg [here](https://regex101.com/)) with this regex instead:

`regex(.'^(?!00)[0-9]{2}$')`

* * *

1. 0-9

---

<div class="post-metadata">

**Author:** ![TanzilHuda](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tanzilhuda/32/9152_2.png) [@TanzilHuda](https://forum.getodk.org/u/TanzilHuda)\
**Post date:** [November 1, 2019, 1:01pm UTC](https://forum.getodk.org/t/how-can-i-make-a-limit-to-the-integer-data-type/23054/8 "2019-11-01T13:01:51Z")

</div>

Thanks everyone. I got the answer. It is:

 ![image](https://getodk.b-cdn.net/uploads/default/original/2X/9/9483b603930f0b0248e0ede0e8ca43761d1e4db4.png)
