Evaluate the first letter in a barcode?

Hello. Is there a way to add a constraint so that the first letter is
evaluated?

For example.
I have a barcode that has labels that start with P and labels that
start with S. I want to make sure for a particular variable they scan
the right barcode. I tried to edit the XML and add:

But, it didn;t stop me from scanning a S barcode.

Thanks!!!

hi alex,

constraints are only evaluated on the swipe to the next screen. also,
your xml isn't correct. you have to do something like this...

note that the regex command has to go inside the constraint attribute.

yaw

··· On Thu, Jun 16, 2011 at 18:12, Alex Pavluck wrote: > Hello. Is there a way to add a constraint so that the first letter is > evaluated? > > For example. > I have a barcode that has labels that start with P and labels that > start with S. I want to make sure for a particular variable they scan > the right barcode. I tried to edit the XML and add: > > regex="^P"/> > > But, it didn;t stop me from scanning a S barcode. > > > Thanks!!! > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

Thanks, Yaw.

So, is this syntax correct:

I want to make sure the barcode starts with a P and then there is
either 6 numbers or a second letter and 5 numbers.

ex.
P123456
or
PZ12345

··· On Jun 16, 3:45 pm, Yaw Anokwa wrote: > hi alex, > > constraints are only evaluated on the swipe to the next screen. also, > your xml isn't correct. you have to do something like this... > > constraint="regex(., > '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}')" > jr:constraintMsg="this isn't a valid email address"/> > > note that the regex command has to go inside the constraint attribute. > > yaw > > > > > > > > On Thu, Jun 16, 2011 at 18:12, Alex Pavluck wrote: > > Hello. Is there a way to add a constraint so that the first letter is > > evaluated? > > > For example. > > I have a barcode that has labels that start with P and labels that > > start with S. I want to make sure for a particular variable they scan > > the right barcode. I tried to edit the XML and add: > > > > regex="^P"/> > > > But, it didn;t stop me from scanning a S barcode. > > > Thanks!!! > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > > Options:http://groups.google.com/group/opendatakit?hl=en

that regex won't work. try

regex(,(P[0-9]{6})|(PZ[0-9]{5}))

··· On Wed, Jun 22, 2011 at 13:43, Alex Pavluck wrote: > Thanks, Yaw. > > So, is this syntax correct: > > constraint="regex(., > '^P\.\d\d\d\d\d\" > jr:constraintMsg="Person ID must begin with a P"/> > > I want to make sure the barcode starts with a P and then there is > either 6 numbers or a second letter and 5 numbers. > > ex. > P123456 > or > PZ12345 > > > > On Jun 16, 3:45 pm, Yaw Anokwa wrote: >> hi alex, >> >> constraints are only evaluated on the swipe to the next screen. also, >> your xml isn't correct. you have to do something like this... >> >> > constraint="regex(., >> '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}')" >> jr:constraintMsg="this isn't a valid email address"/> >> >> note that the regex command has to go inside the constraint attribute. >> >> yaw >> >> >> >> >> >> >> >> On Thu, Jun 16, 2011 at 18:12, Alex Pavluck wrote: >> > Hello. Is there a way to add a constraint so that the first letter is >> > evaluated? >> >> > For example. >> > I have a barcode that has labels that start with P and labels that >> > start with S. I want to make sure for a particular variable they scan >> > the right barcode. I tried to edit the XML and add: >> >> > > > regex="^P"/> >> >> > But, it didn;t stop me from scanning a S barcode. >> >> > Thanks!!! >> >> > -- >> > Post: opendatakit@googlegroups.com >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> > Options:http://groups.google.com/group/opendatakit?hl=en > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

Sorry, I tried the following and it crashes the app after I try to
swipe next:

··· On Jun 22, 2:08 pm, Yaw Anokwa wrote: > that regex won't work. try > > regex(,(P[0-9]{6})|(PZ[0-9]{5})) > > > > > > > > On Wed, Jun 22, 2011 at 13:43, Alex Pavluck wrote: > > Thanks, Yaw. > > > So, is this syntax correct: > > > > constraint="regex(., > > '^P\.\d\d\d\d\d\" > > jr:constraintMsg="Person ID must begin with a P"/> > > > I want to make sure the barcode starts with a P and then there is > > either 6 numbers or a second letter and 5 numbers. > > > ex. > > P123456 > > or > > PZ12345 > > > On Jun 16, 3:45 pm, Yaw Anokwa wrote: > >> hi alex, > > >> constraints are only evaluated on the swipe to the next screen. also, > >> your xml isn't correct. you have to do something like this... > > >> >> constraint="regex(., > >> '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}')" > >> jr:constraintMsg="this isn't a valid email address"/> > > >> note that the regex command has to go inside the constraint attribute. > > >> yaw > > >> On Thu, Jun 16, 2011 at 18:12, Alex Pavluck wrote: > >> > Hello. Is there a way to add a constraint so that the first letter is > >> > evaluated? > > >> > For example. > >> > I have a barcode that has labels that start with P and labels that > >> > start with S. I want to make sure for a particular variable they scan > >> > the right barcode. I tried to edit the XML and add: > > >> > >> > regex="^P"/> > > >> > But, it didn;t stop me from scanning a S barcode. > > >> > Thanks!!! > > >> > -- > >> > Post: opendatakit@googlegroups.com > >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > >> > Options:http://groups.google.com/group/opendatakit?hl=en > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > > Options:http://groups.google.com/group/opendatakit?hl=en

you should run the form through validate
(http://code.google.com/p/opendatakit/downloads/list) before putting
it on the phone. it'll make life a little easier.

anyway, the fix is below.

··· On Wed, Jun 22, 2011 at 15:20, Alex Pavluck wrote: > Sorry, I tried the following and it crashes the app after I try to > swipe next: > > constraint="regex(',(P[0-9]{6})|(PZ[0-9]{5})')"/> > > > > On Jun 22, 2:08 pm, Yaw Anokwa wrote: >> that regex won't work. try >> >> regex(,(P[0-9]{6})|(PZ[0-9]{5})) >> >> >> >> >> >> >> >> On Wed, Jun 22, 2011 at 13:43, Alex Pavluck wrote: >> > Thanks, Yaw. >> >> > So, is this syntax correct: >> >> > > > constraint="regex(., >> > '^P\.\d\d\d\d\d\" >> > jr:constraintMsg="Person ID must begin with a P"/> >> >> > I want to make sure the barcode starts with a P and then there is >> > either 6 numbers or a second letter and 5 numbers. >> >> > ex. >> > P123456 >> > or >> > PZ12345 >> >> > On Jun 16, 3:45 pm, Yaw Anokwa wrote: >> >> hi alex, >> >> >> constraints are only evaluated on the swipe to the next screen. also, >> >> your xml isn't correct. you have to do something like this... >> >> >> > >> constraint="regex(., >> >> '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}')" >> >> jr:constraintMsg="this isn't a valid email address"/> >> >> >> note that the regex command has to go inside the constraint attribute. >> >> >> yaw >> >> >> On Thu, Jun 16, 2011 at 18:12, Alex Pavluck wrote: >> >> > Hello. Is there a way to add a constraint so that the first letter is >> >> > evaluated? >> >> >> > For example. >> >> > I have a barcode that has labels that start with P and labels that >> >> > start with S. I want to make sure for a particular variable they scan >> >> > the right barcode. I tried to edit the XML and add: >> >> >> > > >> > regex="^P"/> >> >> >> > But, it didn;t stop me from scanning a S barcode. >> >> >> > Thanks!!! >> >> >> > -- >> >> > Post: opendatakit@googlegroups.com >> >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> > Options:http://groups.google.com/group/opendatakit?hl=en >> >> > -- >> > Post: opendatakit@googlegroups.com >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> > Options:http://groups.google.com/group/opendatakit?hl=en > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

Is the second letter always going to be a 'Z'? If not then perhaps it should
be constraint="regex(.,'(P[0-9]{6})|(P[A-Z]{1}[0-9]{5})')"/> or something
close to that.

··· On Wed, Jun 22, 2011 at 10:47 PM, Yaw Anokwa wrote:

you should run the form through validate
(http://code.google.com/p/opendatakit/downloads/list) before putting
it on the phone. it'll make life a little easier.

anyway, the fix is below.

On Wed, Jun 22, 2011 at 15:20, Alex Pavluck apavluck@gmail.com wrote:

Sorry, I tried the following and it crashes the app after I try to
swipe next:

On Jun 22, 2:08 pm, Yaw Anokwa yano...@gmail.com wrote:

that regex won't work. try

regex(,(P[0-9]{6})|(PZ[0-9]{5}))

On Wed, Jun 22, 2011 at 13:43, Alex Pavluck apavl...@gmail.com wrote:

Thanks, Yaw.

So, is this syntax correct:

I want to make sure the barcode starts with a P and then there is
either 6 numbers or a second letter and 5 numbers.

ex.
P123456
or
PZ12345

On Jun 16, 3:45 pm, Yaw Anokwa yano...@gmail.com wrote:

hi alex,

constraints are only evaluated on the swipe to the next screen. also,
your xml isn't correct. you have to do something like this...

note that the regex command has to go inside the constraint
attribute.

yaw

On Thu, Jun 16, 2011 at 18:12, Alex Pavluck apavl...@gmail.com wrote:

Hello. Is there a way to add a constraint so that the first letter
is

evaluated?

For example.
I have a barcode that has labels that start with P and labels that
start with S. I want to make sure for a particular variable they
scan

the right barcode. I tried to edit the XML and add:

But, it didn;t stop me from scanning a S barcode.

Thanks!!!

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options:http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options:http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en

--
Steven Nsubuga
Software Developer
AppLab Uganda
Grameen Foundation

Hello Guys,
How do I put a constraint such that only a specific barcode is scanned?
Thanks

Hi @allanodk,

Refer Yaw posts, constraint is evaluated on swipe. With a regex function you achieve that ..