Open End
The OpenEnd question type provides a text area for users to input free-form text responses.
Basic Usage
Parameters
Unique identifier for the question.
The main question text.
Additional text to provide context or instructions.
Minimum required length of the response.
Maximum allowed length of the response.
Number of visible text rows.
Placeholder text for the text area.
Whether the question is required.
Whether to include alias data for typing history.
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
textarea
errorMessage
Data
Response Format
The OpenEnd question type returns a string containing the user’s text input:
Additional data stored includes:
responseLength
: The length of the response.aliasTypingHistory
: An array of typing events ifincludeAlias
is true.
Validation
The OpenEnd question validates that:
- The response is not empty when required is true.
- The response length is at least minLength (if specified).
- The response length does not exceed maxLength (if specified).
- Any custom validation provided in the
customValidation
function passes.
If validation fails, it displays an appropriate error message.
Advanced
Methods
The OpenEnd question type inherits methods from the base Element class and includes some specific methods:
Set the response for the question.
Parameters:
value
(string): The text response
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 open-end question: