const foodPreferencesQuestion = new MultiSelect({ id: 'food_preferences', text: 'Which of the following foods do you enjoy?', options: ['Pizza', 'Sushi', 'Tacos', 'Salad', 'Burgers'], minSelected: 1, maxSelected: 3, required: true });
root
innerContainer
textContainer
text
subText
optionsContainer
option
checkbox
label
errorMessage
["Pizza", "Sushi", "Burgers"]
customValidation
value
multiSelectQuestion.setResponse(['Pizza', 'Sushi']);
isValid
const { isValid, errorMessage } = multiSelectQuestion.validate();
multiSelectQuestion.updateResponse();
const customizedQuestion = new MultiSelect({ id: 'travel_interests', text: 'What types of travel experiences interest you?', subText: 'Select all that apply', options: ['Beach Vacation', 'City Exploration', 'Mountain Hiking', 'Cultural Tours', 'Adventure Sports'], randomize: true, minSelected: 2, maxSelected: 4, required: true, customValidation: (response) => { if (!response.includes('Beach Vacation') && !response.includes('Mountain Hiking')) { return 'Please select at least one nature-related option.'; } return true; }, styles: { root: { backgroundColor: '#f0f8ff', padding: '15px', borderRadius: '8px', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }, text: { color: '#2c3e50', fontSize: '1.2em', fontWeight: 'bold' }, subText: { fontStyle: 'italic', color: '#7f8c8d' }, optionsContainer: { marginTop: '10px' }, option: { marginBottom: '10px', '&:hover': { backgroundColor: '#e0e0e0' } }, checkbox: { accentColor: '#3498db' }, label: { marginLeft: '10px' }, errorMessage: { color: '#e74c3c', fontWeight: 'bold', marginTop: '5px' } } });