+1 vote
  1. Is it possible to set a min and a max number of answers needed to the questions with multiple answers?
  2. Is it possible to set a min and max number of answers for checkboxes too? (e.g., require participants to select 7 options)
by (5.8k points)

1 Answer

0 votes

Only checkbox questions support selecting multiple answers, regular choice questions only support one answer.

Here is how you can set min and max number of checkboxes selected:

>> minOptions = 2
>> maxOptions = 7

*label: checkboxQuestion

*if: showErrorMin
	You need to check at least {minOptions} options

*if: showErrorMax
	You need to check not more {maxOptions} than options


*question: Choose some numbers!
	*tip: You need to check at least {minOptions} and at most {maxOptions} options
	*type: checkbox
	one
	two
	three
	four
	five
	six
	seven
	eight
	nine
	ten
	*save: BoxesChecked
	
*if: (BoxesChecked.size >= minOptions) and (BoxesChecked.size <= maxOptions)
	*goto: continue


*if: BoxesChecked.size <= minOptions
	>> showErrorMin = "yes"
	*goto: checkboxQuestion
	
*if: BoxesChecked.size >= maxOptions
	>> showErrorMax = "yes"
	*goto: checkboxQuestion
	
*label: continue

Great, let's continue!
by (5.8k points)

Thanks for this. I've proposed this feature a while ago, but just wanted to get it circulating again. Why not have a built in min and max parameter to number fields which automatically triggers this label --> goto behavior? For example... right now I have to do something like this for basic numeric field validation:

*label: birth_validate
*question: What is the year of your birth?
	*type: number
	*save: birth
	*throwaway

--Validate birth date
*if: birth < 1900 or birth > 2002
	You must enter a valid birthdate
	*goto: birth_validate

This is a lot of code and makes the overall codebase less readable. It would be much more parsimonious to have a min and a max parameter like so:

*label: birth_validate
*question: What is the year of your birth?
	*type: number
    *min: 1900
    *max: 2002
	*save: birth
	*throwaway

Then the form would automatically yield the label "Must be greater than 1900" or "Must be less than 2000" depending on the user's input.

This would also be preferable since it would allow you to validate multiple fields within a *page. Right now, you can't validate forms (as far as I'm aware) if you have multiple questions on the same page and one of them requires validation.

Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users