const countryQuestion = new DropdownSelect({ id: 'country', text: 'What is your country of residence?', options: ['USA', 'Canada', 'UK', 'Australia', 'Other'], required: true });
root
innerContainer
textContainer
text
subText
select
option
errorMessage
"Canada"
customValidation
value
dropdownSelectQuestion.setResponse('Canada');
isValid
const { isValid, errorMessage } = dropdownSelectQuestion.validate();
const educationQuestion = new DropdownSelect({ id: 'education_level', text: 'What is your highest level of education?', subText: 'Please select the option that best describes your educational background', options: ['High School', 'Associate Degree', 'Bachelor\'s Degree', 'Master\'s Degree', 'Doctorate', 'Other'], required: true, placeholder: 'Choose your education level', customValidation: (response) => { if (response === 'Other') { return 'Please specify your education level in the next question.'; } 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' }, select: { border: '2px solid #3498db', borderRadius: '4px', fontSize: '1.1em', padding: '10px', transition: 'border-color 0.3s ease', '&:focus': { borderColor: '#2980b9', outline: 'none' } }, option: { padding: '10px' }, errorMessage: { color: '#e74c3c', fontWeight: 'bold', marginTop: '5px' } } });