Multiple Select
The MultiSelect question type presents users with a list of options from which they can select multiple answers.
Basic Usage
Parameters
Unique identifier for the question.
The main question text.
Additional text to provide context or instructions.
An array of strings representing the available options.
Whether the question is required.
Whether to randomize the order of options.
The minimum number of options that must be selected.
The maximum number of options that can be selected. If null, there is no maximum.
A custom validation function that takes the response as input and returns true if valid, or an error message string if invalid.
Custom styles to apply to the question. Available keys are:
root
innerContainer
textContainer
text
subText
optionsContainer
option
checkbox
label
errorMessage
Data
Response Format
The MultiSelect question type returns an array of strings representing the selected options:
Validation
The MultiSelect question validates that:
- At least one option is selected when required is true.
- The number of selected options is at least minSelected (if specified).
- The number of selected options does not exceed maxSelected (if specified).
- Any custom validation provided in the
customValidation
function passes.
If validation fails, it displays an error message.
Advanced
Methods
The MultiSelect question type inherits methods from the base Element class and includes some specific methods:
Set the response for the question.
Parameters:
value
(array): An array of selected option strings
Validate the current response against the question’s rules.
Returns:
- An object with
isValid
(boolean) anderrorMessage
(string) properties.
Update the response based on the current state of the checkboxes.
This method is typically called internally when the user interacts with the question.
Example
Here’s an example of how to create a customized multi-select question: