Number Entry
The NumberEntry question type provides a numeric input field for users to enter a numeric value.
Basic Usage
Parameters
Unique identifier for the question.
The main question text.
Additional text to provide context or instructions.
The minimum allowed value. If null, no minimum is enforced.
The maximum allowed value. If null, no maximum is enforced.
The increment value for the input.
The unit of measurement to display next to the input.
Whether the question is required.
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
input
unit
errorMessage
Data
Response Format
The NumberEntry question type returns a string representing the entered numeric value:
The numeric value is also stored separately in the numericValue
data field:
Validation
The NumberEntry question validates that:
- A value is entered when required is true.
- The entered value is a valid number.
- The value is within the specified min and max range (if set).
- Any custom validation provided in the
customValidation
function passes.
If validation fails, it displays an appropriate error message.
Advanced
Methods
The NumberEntry question type inherits methods from the base Element class and includes some specific methods:
Set the response for the question.
Parameters:
value
(string): The numeric value as a string
Validate the current response against the question’s rules.
Returns:
- An object with
isValid
(boolean) anderrorMessage
(string) properties.
Example
Here’s an example of how to create a customized number entry question: