Within Multiple choice questions is there a way we can put a validation where, for the options of none-of-the -above, the other answers get erased or are not entered?
Hello,
could you provide more details, maybe also form what you want to do. If it is just restricting that None can only be selected alone you will find previous community discussion, search for “count-selected”…
Here a constraint example: None (label ‘Z’) to be selected alone and the (others) total to maximal 5,
if( selected(., ‘Z’), count-selected(.) = 1, count-selected(.) <= 5 ).
Kind regards
Hi @anamikadutt,
Would you mind trying out as outlined in the image below to control your none of the above response in a multiple choice question:
In the survey tab of your xlsform:
In the choices tab of your xlsform:
Data entry screen as seen in Enketo: When entered correctly
Data entry screen as seen in Enketo: When entry error is made
Reference xlsform:
Constraint.xlsx (12.6 KB)
Have a great day!
I have tried this but when I try to deploy my survey it always has this message error.
I have 4 choices; a, b, c and d
the condition is:
if a or b chosen, c and d cannot be chosen.
so I wrote the validation like this:
((not(selected(., ‘a’)) and ((selected(.,’c’)) or (selected(.,’d’)))) or (not(selected(., ‘b’)) and ((selected(.,’c’)) or (selected(.,’d’)))) or (not(selected(., ‘c’)) and ((selected(.,’a’)) or (selected(.,’b’)))) or (not(selected(., ‘d’)) and ((selected(.,’a’)) or (selected(.,’b’)))))
the code works, but not in the way that I want it.
The error message only shows when the 4 choices were selected at once.
Please help me to find where I went wrong.
Thanks.
In this case, maybe you could do it as shown in the image shared below using this expressions in the constraint:
not(selected(., ‘c’) and (selected(.,’a’) or selected(.,’b’))) and not(selected(., ‘d’) and (selected(.,’a’) or selected(.,’b’)))
In the survey tab of your xlsform:
In the choices tab of your xlsform:
Data entry screen as seen in Enekto: when data is entered as expected
Data entry screen as seen in Enekto: when data is not entered as expected
Data entry screen as seen in Enekto: when data is entered as expected
Data entry screen as seen in Enekto: when data is not entered as expected
Reference xlsform:
Constraint.xlsx (12.4 KB)
It works! it works! it works!
Thank you very much!