const ageQuestion = new NumberEntry({ id: 'age', text: 'What is your age?', min: 18, max: 120, required: true });
root
innerContainer
textContainer
text
subText
input
unit
errorMessage
"25"
numericValue
this.data.numericValue = 25
customValidation
value
numberEntryQuestion.setResponse('25');
isValid
const { isValid, errorMessage } = numberEntryQuestion.validate();
const temperatureQuestion = new NumberEntry({ id: 'room_temperature', text: 'What is your preferred room temperature?', subText: 'Enter a value between 60 and 80 degrees', min: 60, max: 80, step: 0.5, unit: '°F', required: true, customValidation: (response) => { const value = parseFloat(response); if (value % 1 !== 0.5 && value % 1 !== 0) { return 'Please enter a whole number or half degree (e.g., 72 or 72.5)'; } 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' }, input: { width: '100px', border: '2px solid #3498db', borderRadius: '4px', fontSize: '1.1em', padding: '5px' }, unit: { marginLeft: '10px', color: '#34495e', fontSize: '1em' }, errorMessage: { color: '#e74c3c', fontWeight: 'bold', marginTop: '5px' } } });