# Choice filter depent Age

**URL:** <https://forum.getodk.org/t/choice-filter-depent-age/20957>\
**Category:** Support\
**Created:** [July 16, 2019, 9:53pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957 "2019-07-16T21:53:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Pineros](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_pineros/32/7808_2.png) [@Samuel\_Pineros](https://forum.getodk.org/u/Samuel_Pineros)\
**Post date:** [July 16, 2019, 9:53pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/1 "2019-07-16T21:53:54Z")

</div>

Hi,

Well Im new in ODK and I try to create a form with a lot of validations.

1. I calculate the age depending on the birth date, after I need to create this validation:

If age \< 18 Document Type = TI  
If age \>= 18 Document Type = CC

1. I need a regex, that only receives capital letters.

Can someone help me? please.

---

<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:** [July 17, 2019, 7:56am UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/2 "2019-07-17T07:56:51Z")

</div>

> [@Samuel\_Pineros](#):
>
> If age \< 18 Document Type = TI  
> If age \>= 18 Document Type = CC  
> ...  
> I need a regex, that only receives capital letters.

Please make sure to review [https://docs.opendatakit.org/form-logic/#validating-and-restricting-responses](https://docs.opendatakit.org/form-logic/#validating-and-restricting-responses), which should explain how to accomplish these constraint checks. If you still have any questions afterwards please post back.

---

<div class="post-metadata">

**Author:** ![Samuel\_Pineros](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_pineros/32/7808_2.png) [@Samuel\_Pineros](https://forum.getodk.org/u/Samuel_Pineros)\
**Post date:** [July 17, 2019, 1:05pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/3 "2019-07-17T13:05:36Z")

</div>

Hi @Xiphware, yes I check ODK documentation before posting the question and I try difrent methods or formulas, but it doesn't work 😔 in the case 1, and in the case 2 its not clear for me the construction of the expresion I try this: regex(.,'[A-Z]'), but it doesn't work.

---

<div class="post-metadata">

**Author:** ![aurdipas](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aurdipas/32/1785_2.png) [@aurdipas](https://forum.getodk.org/u/aurdipas)\
**Post date:** [July 17, 2019, 2:26pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/4 "2019-07-17T14:26:04Z")

</div>

hi @Samuel_Pineros

regex(., "^[A-Z]{1,10}$") will allow you to enter only uppercase text minimum length 1 to max length 10.

---

<div class="post-metadata">

**Author:** ![Samuel\_Pineros](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_pineros/32/7808_2.png) [@Samuel\_Pineros](https://forum.getodk.org/u/Samuel_Pineros)\
**Post date:** [July 17, 2019, 2:41pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/5 "2019-07-17T14:41:18Z")

</div>

Thanks @aurdipas, I have a quiestion, Is it mandatory to stipulate the length? Is there an option to apply to all the text that the user enters?

---

<div class="post-metadata">

**Author:** ![dicksonsamwel](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/dicksonsamwel/32/2898_2.png) [@dicksonsamwel](https://forum.getodk.org/u/dicksonsamwel)\
**Post date:** [July 17, 2019, 6:09pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/6 "2019-07-17T18:09:49Z")

</div>

Hi @Samuel_Pineros,

> [@Samuel\_Pineros](#):
>
> Is it mandatory to stipulate the length?

Yes.

> [@Samuel\_Pineros](#):
>
> Is there an option to apply to all the text that the user enters?

No, you have to apply the regex for all the text question you want to check.

---

<div class="post-metadata">

**Author:** ![aurdipas](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aurdipas/32/1785_2.png) [@aurdipas](https://forum.getodk.org/u/aurdipas)\
**Post date:** [July 17, 2019, 7:06pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/7 "2019-07-17T19:06:01Z")

</div>

anyway the limit of a text field is by default 255 so you can specify regex(., "^[A-Z]{1,255}$")  
If you want longer text then look here [https://docs.opendatakit.org/aggregate-field-length/](https://docs.opendatakit.org/aggregate-field-length/)

---

<div class="post-metadata">

**Author:** ![Samuel\_Pineros](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_pineros/32/7808_2.png) [@Samuel\_Pineros](https://forum.getodk.org/u/Samuel_Pineros)\
**Post date:** [July 17, 2019, 7:22pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/8 "2019-07-17T19:22:14Z")

</div>

Thanks @dicksonsamwel, can you help me with point number 1.? It's possible to do this?

---

<div class="post-metadata">

**Author:** ![Samuel\_Pineros](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_pineros/32/7808_2.png) [@Samuel\_Pineros](https://forum.getodk.org/u/Samuel_Pineros)\
**Post date:** [July 17, 2019, 7:23pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/9 "2019-07-17T19:23:03Z")

</div>

Thanks again @aurdipas, can you help me with point number 1.? It's possible to do this?

---

<div class="post-metadata">

**Author:** ![dicksonsamwel](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/dicksonsamwel/32/2898_2.png) [@dicksonsamwel](https://forum.getodk.org/u/dicksonsamwel)\
**Post date:** [July 17, 2019, 8:12pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/10 "2019-07-17T20:12:10Z")

</div>

One option will be to use a hidden calculate question. After getting the age, you can use if statement to set the DocumentType variable.  
ie `if(${age} >= 18, 'CC', 'TI')`

---

<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:** [July 17, 2019, 9:22pm UTC](https://forum.getodk.org/t/choice-filter-depent-age/20957/11 "2019-07-17T21:22:49Z")

</div>

> [@dicksonsamwel](#):
>
> > Is it mandatory to stipulate the length?
> 
> Yes.

Actually strictly speaking its not. The regex qualifier '`*`' will match zero or more; the qualifier '`+`' will match 1 or more. So the following will ensure all the chars are uppercase:

`regex(., "^[A-Z]*$")`
