Validation on two integer in ODk


1. What is the problem? Be very detailed.

i have a question in survey,
"Q1.Working Experience?" and answer captured in two integers "Years" and "Months".

how can i validate them, the responses must be follow below conditions..

  1. Years must be 0-50
  2. Months must be 0-11
  3. (years = 0 and Month >= 1) or (years >= 1 and Month = 0) or (years >= 1 and Month >= 1)

2. What app or server are you using and on what device and operating system? Include version numbers.

ODK Application, ODK Aggregate

3. What you have you tried to fix the problem?

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

So years must be 0-50 and months 0-11 but they can't both be 0 at the same time?

yes, you are right they both can't 0 at same time

So I think constraint for year would be:

.>=0 and .<=50

and for month:

.>=0 and .<=11 and ${year}>0 or .>0

yearMonth.xlsx (4.9 KB)

I think you may need an explicit parens; ie

.>=0 and .<=11 and (${year}>0 or .>0)

because or has a lower precedence than and in XPath boolean expressions