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
···
On Tue, May 12, 2015 at 5:46 PM, Susana Benitez wrote:
Hello,
I am looking to put in place a restriction 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 restriction regex(.,'{4}$'). How do I add the 6-digit
restriction 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.
I haven't tried, but you can try this regex that adds an optional 2 digits group at the end:
regex(.,'^[:digit:]{4}([:digit:]{4})?$')
···
On Tuesday 12 May 2015 18:11:29 Clayton Sims wrote:
> 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
>
> On Tue, May 12, 2015 at 5:46 PM, Susana Benitez wrote:
>
> > Hello,
> > I am looking to put in place a restriction 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 restriction *regex(.,'^[:digit:]{4}$')*. How do I add the 6-digit
> > restriction 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.
> >
>
>
--
Charles Flèche
mHealth Advisor
Télécoms Sans Frontières http://www.tsfi.org
Première Urgence - Aide Médicale Internationale http://www.pu-ami.org
Woopsie, should I wrote :
regex(.,'^[:digit:]{4}([:digit:]{2})?$')
···
On Wednesday 13 May 2015 14:47:26 Charles Flèche wrote:
> I haven't tried, but you can try this regex that adds an optional 2 digits group at the end:
>
>
>
>
>
>
> On Tuesday 12 May 2015 18:11:29 Clayton Sims wrote:
> > 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
> >
> > On Tue, May 12, 2015 at 5:46 PM, Susana Benitez wrote:
> >
> > > Hello,
> > > I am looking to put in place a restriction 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 restriction *regex(.,'^[:digit:]{4}$')*. How do I add the 6-digit
> > > restriction 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.
> > >
> >
> >
>
>
--
Charles Flèche
mHealth Advisor
Télécoms Sans Frontières http://www.tsfi.org
Première Urgence - Aide Médicale Internationale http://www.pu-ami.org