Choice filter depent Age

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.

Please make sure to review 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.

Hi @Xiphware, yes I check ODK documentation before posting the question and I try difrent methods or formulas, but it doesn't work :pensive: 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.

hi @Samuel_Pineros

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

1 Like

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?

Hi @Samuel_Pineros,

Yes.

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

1 Like

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/

1 Like

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

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

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')

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]*$")

1 Like