Validation of a list question

Hie friends, I would like to validate a list question to only provide a space to list a number equal to what was reported in the previous question. For example the first question is “How many people are currently living with you?” and if they say there are 5 people, the next question will ask " Please list the names of all the people you are currently living with" and this question should only allow them to list a maximum of 5 names as previously stated. is there a way to do this and How do I write the validation in survey solutions

The maximum number of answers that can be provided in the list is a fixed property of a list question. See an example here, where I’ve set the max to 60.

But one can implement a validation that throws an error whenever the length of the list is less than expected length. In the most basic form, it may look like this, where my_list_question is the list question and my_count is a numeric question that captures expected list length, and Length is a property of list questions

my_list_question.Length == my_count

To check the length only when these questions have been answered, consider revising to something like this:

// if the list and count questions are answered...
IsAnswered(my_count) && IsAnswered(my_list_question) ? 

// ... then check that the expected length and actual length are the same
my_list_question.Length == my_count :

// otherwise, everything is OK
1 Like

This is better solved by a text question in a roster triggered by the numeric question “How many people are currently living with you?

Thank you. I will try this as well.

Thank you so much. I will try to use this

This has work perfectly