Long Text
A Long Text (or Comment) question is a multi-line text input field that allows users to give detailed responses and share their feelings, experiences, or opinions on a subject. Unlike single- or multi-select questions that offer predefined options, a Long Text question asks respondents to express their thoughts in their own words. This example demonstrates how to create and configure a Long text question. Switch between React, Vue, Knockout, jQuery, and Angular to view the example for your JavaScript framework.
Create a Long Text Question
To create a Long Text form field, define an object with the type
property set to "comment"
and add it to the elements
array. Within this object, specify the question's title
and a unique name
that identifies the question. Optionally, you can specify a description
to appear under the title
and a placeholder
to display within the comment area.
Resize the Comment Area
The comment area of a Long Text question occupies the height of four rows of text on the screen. If you want to change this number and increase or decrease the height, set the rows
property.
When the content exceeds the comment area, a vertical scrollbar appears. Enable the autoGrow
property if you want the comment area to automatically expand or shrink to accommodate the content and thus remove the scrollbar. You can also enable SurveyModel
's autoGrowComment
property to activate the same feature for all comment areas in a survey.
A Long Text question displays a resize handle that allows users to resize the comment area. If you want to hide the handle, disable the allowResize
property in an individual Long Text question's configuration or the allowResizeComment
in SurveyModel
. The latter property hides the resize handle for all comment areas.
Limit the Number of Input Characters
A Long Text form field accepts an unlimited number of characters. If you want to set a limit, use the maxLength
property. With this setting, the comment area displays a character count.