Digit Validation Condition

Hello,
I am looking to put in place a validation condition for one integer
question. I want the interviewer to only be able to enter EITHER a 4-digit
number OR a 6-digit number. As of right now, I only have the following
4-digit validation regex(.,'^[:digit:]{4}$'). How do I add the 6-digit
validation as well?

Thank you,
Susana

Hello Susana,

You can simply use or between the two regex() validation conditions.
Please see Example 5 on this page
https://confluence.dimagi.com/display/commcarepublic/Common+Logic+and+Calculations#CommonLogicandCalculations-RequireSpecificallyFormattedNumericInputs
.

Hope this answers your question.

Thanks,
Kriti

··· On Tue, May 12, 2015 at 11:17 PM, Susana Benitez wrote:

Hello,
I am looking to put in place a validation condition for one integer
question. I want the interviewer to only be able to enter EITHER a 4-digit
number OR a 6-digit number. As of right now, I only have the following
4-digit validation regex(.,'[1]{4}$'). How do I add the 6-digit
validation as well?

Thank you,
Susana

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1. :digit: ↩︎

Thank you Kriti. Do you mean like this *regex(.,'^[:digit:]{4}$' or
'^[:digit:]{6}$') *? I have tried it and it gives me an error. I also tried
making them separate, as in *regex(.,'^[:digit:]{4}$') or *
regex(.,'^[:digit:]{6}$') but it also gives me an error.

Thank you for your help,
Susana

··· On Tuesday, May 12, 2015 at 2:01:45 PM UTC-4, Kriti Mehrotra wrote: > > Hello Susana, > > You can simply use *or* between the two regex() validation conditions. > Please see Example 5 on this page > > . > > Hope this answers your question. > > Thanks, > Kriti > > On Tue, May 12, 2015 at 11:17 PM, Susana Benitez <sbeni...@gmail.com > wrote: > >> Hello, >> I am looking to put in place a validation condition for one integer >> question. I want the interviewer to only be able to enter EITHER a 4-digit >> number OR a 6-digit number. As of right now, I only have the following >> 4-digit validation *regex(.,'^[:digit:]{4}$')*. How do I add the 6-digit >> validation as well? >> >> Thank you, >> Susana >> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >

Hi Susana,

I'll take the liberty of pointing you to Clayton's response on the other
email thread with the same question from you (I think we got duplicates).
Just in case you're not able to see it there, I'm pasting it here:

Susana,

We have a specific data-type in CommCare's form builder called "Phone
Number/Numeric ID" which you might find helpful. It restricts the users to
typing numbers, but retains things like leading 0's.
There's also a string-length function which you could use which will tell
you how long a question's answer is,
string-length(.) = 4 or string-length(.) = 6 would be able to test whether
the input was of the lengths you are looking for.

-Clayton​

If you're still having trouble making it work, do let us know.

Thanks,
Kriti

··· On Tue, May 12, 2015 at 11:42 PM, Susana Benitez wrote:

Thank you Kriti. Do you mean like this *regex(.,'[1]{4}$' or
'[2]{6}$') *? I have tried it and it gives me an error. I also
tried making them separate, as in *regex(.,'[3]{4}$') or *
regex(.,'[4]{6}$') but it also gives me an error.

Thank you for your help,
Susana

On Tuesday, May 12, 2015 at 2:01:45 PM UTC-4, Kriti Mehrotra wrote:

Hello Susana,

You can simply use or between the two regex() validation conditions.
Please see Example 5 on this page
https://confluence.dimagi.com/display/commcarepublic/Common+Logic+and+Calculations#CommonLogicandCalculations-RequireSpecificallyFormattedNumericInputs
.

Hope this answers your question.

Thanks,
Kriti

On Tue, May 12, 2015 at 11:17 PM, Susana Benitez sbeni...@gmail.com wrote:

Hello,
I am looking to put in place a validation condition for one integer
question. I want the interviewer to only be able to enter EITHER a 4-digit
number OR a 6-digit number. As of right now, I only have the following
4-digit validation regex(.,'[5]{4}$'). How do I add the
6-digit validation as well?

Thank you,
Susana

--
You received this message because you are subscribed to the Google
Groups "commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to commcare-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1. :digit: ↩︎

  2. :digit: ↩︎

  3. :digit: ↩︎

  4. :digit: ↩︎

  5. :digit: ↩︎