Building a complex regex constraint to match the entry between an entry made in the previous question and the later question

Capture
Hi guys, I want you to show an error message when entering the wrong letter, as illustrated in the photo. How do I do?

You could do this through the regex code as outlined in the support article Restricting Text Responses With Regular Expressions.

I can have an example. I tried to do it using regex a week ago and I can’t.

You could do it as outlined in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo: when a wrong entry is made

Data entry screen as seen in Enketo: when a correct entry is made

Reference xlsform:

Regex.xlsx (10.3 KB)

Hello Kal_Lam,
The user must enter the same letters in the Cadastral Block and Parcel Code field.
If he enters a different letter, it should display an error message.

Kal_Lam via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia sexta, 6/08/2021 Ă (s) 15:36:

@finercia_americo, did the above regex code not work?

It didn’t work for this problem. I want to put a dependency, the letters that are put in the first field must be the same ones in the second field.

Kal_Lam via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia segunda, 9/08/2021 Ă (s) 19:17:

So you mean if you enter say Test in the first question, your second question should allow only Test? Did I now get it correctly?

If you enter A in the first question, the second question must be A001. So, I must put an error message if the user enters A in the first question and in the second question AA001.
The letters entered range from A-I and the digits from 0-9, you can enter up to 3 digits.

Kal_Lam via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia terça, 10/08/2021 à(s) 09:46:

And so what would it be like in the second question if you enter B in the first question?

It would be B001 or B002 to B009

Kal_Lam via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia terça, 10/08/2021 à(s) 11:00:

A 3-digit combination of 0-9

Finércia Américo Chandamela <finerciaachandamela@gmail.com> escreveu no dia terça, 10/08/2021 à(s) 11:07:

I want a condition that says that the code letters painted in red must match. The letters entered in the first field must be the same as in the second.

Finércia Américo Chandamela <finerciaachandamela@gmail.com> escreveu no dia terça, 10/08/2021 à(s) 11:11:

Question.xlsx (11.2 KB)

Hi @finercia_americo
If you look at the use of constraints, you should be able to apply constraints together with the indicated logic by @Kal_Lam

  1. Use the regex for the first question
    2…Use constraints to ensure the second question equals the first question.

Regards
Stephane

1 Like

I’m sorry but I can’t solve it

Stephane Aloo via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia terça, 10/08/2021 à(s) 18:44:

@finercia_americo, this could be a bit complex but you could do it as outlined in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo: when a wrong entry is made

Data entry screen as seen in Enketo: when a correct entry is made

Data entry screen as seen in Enketo: when a wrong entry is made

Data entry screen as seen in Enketo: when a correct entry is made

Reference xlsform:

Regex.xlsx (10.7 KB)

1 Like

Thank you very much for your attention. I managed to implement.

Kal_Lam via KoBoToolbox Community Forum <noreply@community.kobotoolbox.org> escreveu no dia segunda, 16/08/2021 Ă (s) 09:09:

1 Like