Validation Based on Previous Response

Hi,

Is it possible to build in validation based on a previous response?

e.g. If the answer to "How old are you?" is 25, the validation range for
"How many years have you smoked?" would be 12-25, while the overall range
for the question might be 12-65.

Any suggestions/advice on this point would be greatly appreciated.

Best,
Audrey

Hi Audrey,
Yes, this is possible. Not sure if this is the most efficient way, but the
following seems to work for your use case.

  • add a constraint on age:".>= 12 and .<=100"
  • after age, you add a calculate question that calculates the maximum years
    smoked based on the age: "/constraint/age - 12" The user won't see this.
  • on the 'Years smoked' question, you add a constraint so the answer is
    than the max_years_smoked and less than 65: ".<=
    /constraint/max_years_smoked and .<= 65"

Example XML on: https://gist.github.com/olafveerman/5089981
best,
Olaf

··· On 5 March 2013 10:40, wrote:

Hi,

Is it possible to build in validation based on a previous response?

e.g. If the answer to "How old are you?" is 25, the validation range for
"How many years have you smoked?" would be 12-25, while the overall range
for the question might be 12-65.

Any suggestions/advice on this point would be greatly appreciated.

Best,
Audrey

--

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/groups/opt_out.

1 Like