Validation criteria - two mutually exclusive answers

Hello,

I am creating a survey and one of the questions is regarding items of aid respondents have received. This is a select all that apply question, however, there are two answers in here mutually exclusive; there are two different water filters that were supplied, everyone will only have been given one. I am trying to write a validation criteria code to make sure only one to the water filters has been selected and have tried the following:

not(selected(.,‘a’) and (selected(.,‘b’))

‘a’ and ‘b’ in this case being the name for the different water filters.

When previewing the survey, it now gives the error message as soon as any answer has been given to this question, regardless of that being ‘a’, ‘b’ or a completely different option.

Does anyone have any suggestions how to make this work?

Thanks!

Welcome to the community @ChannavanLeijsen,

In order for community to understand your issue clearly, can you provide a screenshot of the error message and the constraint formula of the question?

Thank you for the warm welcome!

Of course,

Hi @ChannavanLeijsen,

Can you also provide a screenshot of your answers with their XML values? (The XML values are on the right side of your answers)

Yes, here it is:

1 Like

And just to be complete, here is also a screenshot of the preview, showing the constraint message appearing even when selecting a completely different answer:

1 Like

Hi @ChannavanLeijsen,

Can you change the validation code to:

not(selected(.,'a') and selected(.,'b'))

Let’s see if that works.

It does! Thank you Hakan! I really thought I had tried all the different options, but this one did the trick.

1 Like

@ChannavanLeijsen, maybe this post discussed previously should help you solve your issue: