Hi all, I would really appreciate your help on this!
I want to create a validation condition if ONE choice is made depending on
an answer to a previous question.
E.g. If someone chooses child in one section, however in the previous
question they stated the age of the beneficiary to be over 18, I want to
stop them being able to make that choice with a message confirming why.
Can you make separate validation conditions (with separate messages) for
different choices?
Thanks,
Heidi
Hi Heidi,
Just tried it on a test application:
First question
Type: Integer
ID: age
Second question
Type: Single choice
Choices: Child / Adult
ID: growth_status
Validate condition: if(selected(., "child"), /data/age < 18, /data/age >= 18)
As a reminder, the dot in the "selected" refers to the current question (growth_status)
And it works: the question is not validated if 'age' does not match 'grow_status'
But if I were you I wouldn't have a growth_status question : I'd fill an hidden value according to 'age', something like:
Hidden value
ID: growth_status
Calculate Condition: if(/data/age < 18, 'child', 'adult')
Hope it helps,
Charles
···
On Tuesday 05 May 2015 04:41:46 Heidi Lowe wrote:
> Hi all, I would really appreciate your help on this!
>
> I want to create a validation condition if ONE choice is made depending on
> an answer to a previous question.
>
> E.g. If someone chooses child in one section, however in the previous
> question they stated the age of the beneficiary to be over 18, I want to
> stop them being able to make that choice with a message confirming why.
>
> Can you make separate validation conditions (with separate messages) for
> different choices?
>
> Thanks,
>
> Heidi
>
>
--
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
Thank You so much for your help Charles, this works perfectly!
···
On Tuesday, 5 May 2015 18:14:03 UTC+6, Charles Flèche wrote:
>
> Hi Heidi,
>
>
>
> Just tried it on a test application:
>
>
>
> First question
>
> Type: Integer
>
> ID: age
>
>
>
> Second question
>
> Type: Single choice
>
> Choices: Child / Adult
>
> ID: growth_status
>
> Validate condition: if(selected(., "child"), /data/age < 18, /data/age >=
> 18)
>
>
>
> As a reminder, the dot in the "selected" refers to the current question
> (growth_status)
>
>
>
> And it works: the question is not validated if 'age' does not match
> 'grow_status'
>
>
>
> But if I were you I wouldn't have a growth_status question : I'd fill an
> hidden value according to 'age', something like:
>
>
>
> Hidden value
>
> ID: growth_status
>
> Calculate Condition: if(/data/age < 18, 'child', 'adult')
>
>
>
> Hope it helps,
>
>
>
> Charles
>
>
>
>
>
> On Tuesday 05 May 2015 04:41:46 Heidi Lowe wrote:
>
> > Hi all, I would really appreciate your help on this!
>
> >
>
> > I want to create a validation condition if ONE choice is made depending
> on
>
> > an answer to a previous question.
>
> >
>
> > E.g. If someone chooses child in one section, however in the previous
>
> > question they stated the age of the beneficiary to be over 18, I want to
>
> > stop them being able to make that choice with a message confirming why.
>
> >
>
> > Can you make separate validation conditions (with separate messages) for
>
> > different choices?
>
> >
>
> > Thanks,
>
> >
>
> > Heidi
>
> >
>
> >
>
>
>
> --
>
> 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
>
>
>