Comparing two string prompts regardless of their cases

I've two string prompts (free texts) that expect restricted foods in any
community. I want to validate that these prompts don't allow same food
type. eg. Foodtype1 = 'Fish' and Foodtype2 = 'Fish' which is considered
invalid. I tried to compare two food prompts value

  •  <bind nodeset="/data/Foodtype1" type="string"/>*
    
  •  <bind nodeset="/data/Foodtype2" type="string" 
    

constraint="string(/data/Foodtype1) != string(/data/Foodtype2)"
jr:constraintMsg="Food type already entered!!"/>*

with this, i found that it only works if both the entries are exactly the
same (both has to be in upper/lower case). If Foodtype1 = 'fish' and
Foodtype2 = 'Fish', then the comparision allows the inputs and moves
forward. I could use regex to input only lower cases or upper cases but we
can only use one constraint for a node. Is there a way to go about it. What
could be the work around so that entries like below (1 and 2) can be avoided
and entries like 3 is considered valid.

1. Foodtype1 = 'fish' and Foodtype2 = 'Fish' (invalid)
2. Foodtype1 = 'fisH' and Foodtype2 = 'Fish' (invalid) or any such
combinations of cases.

3. Foodtype1 = 'fish' and Foodtype2 = 'egg' (valid)

I'm pretty sure you can use multiple constraints in a node. Build a small
one question form and test it.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Wed, Aug 19, 2015 at 3:53 AM, ChangbangMobs chayan.s@ptas.com.np wrote:

I've two string prompts (free texts) that expect restricted foods in any
community. I want to validate that these prompts don't allow same food type.
eg. Foodtype1 = 'Fish' and Foodtype2 = 'Fish' which is considered invalid. I
tried to compare two food prompts value

  <bind nodeset="/data/Foodtype1" type="string"/>
  <bind nodeset="/data/Foodtype2" type="string"

constraint="string(/data/Foodtype1) != string(/data/Foodtype2)"
jr:constraintMsg="Food type already entered!!"/>

with this, i found that it only works if both the entries are exactly the
same (both has to be in upper/lower case). If Foodtype1 = 'fish' and
Foodtype2 = 'Fish', then the comparision allows the inputs and moves
forward. I could use regex to input only lower cases or upper cases but we
can only use one constraint for a node. Is there a way to go about it. What
could be the work around so that entries like below (1 and 2) can be avoided
and entries like 3 is considered valid.

  1. Foodtype1 = 'fish' and Foodtype2 = 'Fish' (invalid)
  2. Foodtype1 = 'fisH' and Foodtype2 = 'Fish' (invalid) or any such
    combinations of cases.
  3. Foodtype1 = 'fish' and Foodtype2 = 'egg' (valid)

--

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


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

Javarosa does not provide a "to-lower-case(${fieldname})" function. I think
that is what you would need.

If you do not need to support arbitrary values, use a select and a
predefined choice list to avoid the spelling and upper/lower case problem.

This will also simplify your data analysis later, since you won't be
dealing with one survey with 'Fish' and a second survey with 'fish', and
have to manually reconcile them later.

And if you have to, you can have an 'other' choice with manual entry. But
having a large list of predefined choices will make everything easier.

If you are absolutely convinced that you must have free-form data entry for
these fields, this is most easily handled through the training of your data
collectors.

··· On Wed, Aug 19, 2015 at 8:30 AM, Yaw Anokwa wrote:

I'm pretty sure you can use multiple constraints in a node. Build a small
one question form and test it.

Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Wed, Aug 19, 2015 at 3:53 AM, ChangbangMobs chayan.s@ptas.com.np wrote:

I've two string prompts (free texts) that expect restricted foods in any
community. I want to validate that these prompts don't allow same food
type.
eg. Foodtype1 = 'Fish' and Foodtype2 = 'Fish' which is considered
invalid. I
tried to compare two food prompts value

  <bind nodeset="/data/Foodtype1" type="string"/>
  <bind nodeset="/data/Foodtype2" type="string"

constraint="string(/data/Foodtype1) != string(/data/Foodtype2)"
jr:constraintMsg="Food type already entered!!"/>

with this, i found that it only works if both the entries are exactly the
same (both has to be in upper/lower case). If Foodtype1 = 'fish' and
Foodtype2 = 'Fish', then the comparision allows the inputs and moves
forward. I could use regex to input only lower cases or upper cases but
we
can only use one constraint for a node. Is there a way to go about it.
What
could be the work around so that entries like below (1 and 2) can be
avoided
and entries like 3 is considered valid.

  1. Foodtype1 = 'fish' and Foodtype2 = 'Fish' (invalid)
  2. Foodtype1 = 'fisH' and Foodtype2 = 'Fish' (invalid) or any such
    combinations of cases.
  3. Foodtype1 = 'fish' and Foodtype2 = 'egg' (valid)

--

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


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

--

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


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

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thnx Yaw for the suggestion. multiple conditions in the constraint solved
my problem.

··· On Wednesday, August 19, 2015 at 9:16:30 PM UTC+5:45, Yaw Anokwa wrote: > > I'm pretty sure you can use multiple constraints in a node. Build a small > one question form and test it. > > Yaw > -- > Need ODK services? http://nafundi.com provides form design, server > setup, professional support, and software development for ODK. > > On Wed, Aug 19, 2015 at 3:53 AM, ChangbangMobs <chay...@ptas.com.np > wrote: > > I've two string prompts (free texts) that expect restricted foods in any > > community. I want to validate that these prompts don't allow same food > type. > > eg. Foodtype1 = 'Fish' and Foodtype2 = 'Fish' which is considered > invalid. I > > tried to compare two food prompts value > > > > > > > constraint="string(/data/Foodtype1) != string(/data/Foodtype2)" > > jr:constraintMsg="Food type already entered!!"/> > > > > with this, i found that it only works if both the entries are exactly > the > > same (both has to be in upper/lower case). If Foodtype1 = 'fish' and > > Foodtype2 = 'Fish', then the comparision allows the inputs and moves > > forward. I could use regex to input only lower cases or upper cases but > we > > can only use one constraint for a node. Is there a way to go about it. > What > > could be the work around so that entries like below (1 and 2) can be > avoided > > and entries like 3 is considered valid. > > > > 1. Foodtype1 = 'fish' and Foodtype2 = 'Fish' (invalid) > > 2. Foodtype1 = 'fisH' and Foodtype2 = 'Fish' (invalid) or any such > > combinations of cases. > > 3. Foodtype1 = 'fish' and Foodtype2 = 'egg' (valid) > > > > -- > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > --- > > You received this message because you are subscribed to the Google > Groups > > "ODK Community" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to opendatakit...@googlegroups.com . > > For more options, visit https://groups.google.com/d/optout. >