Our Long Text question is ideal when you want people to share their opinion and write long answers.
You can also allow answers of any length or set a character limit, make the question required, and validate response formats.
Add a Long Text question to your form
To add a Long Text question to your form:
- Open up an existing form from a Workspace, and click + Add content.
- Select Long Text from the list.
- Write your question, and optionally, add a description.
- Under Question settings, toggle the Required switch to make your Long Text question required. This way people won’t be able to skip the Long Text question in your form.
- By default, there is no character limit on answers submitted to the Long Text question. You can toggle the Max characters switch to manually set a character limit. In the example below, the limit has been set to 500 characters.
- If you’re on an Enterprise plan, you can also toggle the Answer validation switch to validate the input provided by your respondents using regular expressions (RegEx). This can come in handy when you want to make sure the information you’re collecting is in the correct format and doesn’t contain any errors, for example, when collecting information about official documents, bank account numbers, or anything that requires a specific format.
- In the example below, we’re asking for a Spanish bank account number, and we want to make sure that the information provided is in a valid format.
- To get a specific validation pattern, simply ask for it in the Typeform AI chat. In the example below, we ask for a regex pattern for a Spanish IBAN.
- Copy and paste the regex pattern into the Answer validation field, and click Share or Publish edits to share your form with the world.
- If a respondent enters a bank account number that doesn’t match your validation criteria, they’ll see an error message and won’t be able to continue until their answer is in a valid format.
- Finally, you can click Design to apply a theme to your form, or click + next to Image or video to add an image or video to your Long Text question.
You can find out more about our design tools here and here.
Common validation pattern examples
Some of the common validation pattern examples are the following:
- Email Validation
```
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$
```- Phone Number (International)
```
^\\+?[1-9]\\d{1,14}$
```- US Postal Code
```
^\\d{5}(-\\d{4})?$
```- URL (HTTP/HTTPS)
```
^https?://[\\w.-]+\\.[a-z]{2,}(/.*)?$
```- Date (YYYY-MM-DD)
```
^\\d{4}-\\d{2}-\\d{2}$
```- Alphanumeric (3-10 characters)
```
^[A-Za-z0-9]{3,10}$
```Pattern Complexity
Complex patterns can impact form performance. Keep patterns simple and efficient:
Good: ^\d{3}-\d{4}$
-
Precision:
^\d{3}-\d{4}$enforces a specific format - Clarity: easy to read
- Efficiency: simple and fast
-
Redundancy:
\d+and[0-9]+are the same thing
Bad: `^(\d+|\w+|[a-z]+|[A-Z]+|[0-9]+)*$`
- Precision: allows almost anything
- Clarity: confusing, redundant, hard to maintain
- Efficiency: unnecessary alternations and repetition are slower and harder for regex engine
-
Redundancy:
[a-z]+,[A-Z]+are already covered by\w+
Make sure to use ^\d{3}-\d{4}$ if you want strict patterns, for example, a phone extension or a postal code.
You can find out more about how to use JavaScript RegExp references here.