Answer validation

When collecting responses to questions in your form, ensuring the accuracy and consistency of the answers is essential. Answer validation allows you to define specific rules that responses must meet before they can be submitted, helping you maintain reliable data and reduce the need for manual review.

Typeform offers validation in two ways:

  • Built-in validation for the following question types:
    • Email - verifies that responses follow a valid email format (xxxx@yyy.zzz)
    • Website - verifies that responses follow a valid URL format (https://xxxx.yyy, www.yyyy.zzz, xxxx.yyy)
    • Phone number - respondents select their country code and each country is configured to only accept correctly formatted phone numbers
    • Date - verifies that responses follow the date format you choose (MMDDYYYY, DDMMYYYY, YYYYMMDD)
    • Number - only accepts positive whole numbers as a response

 

  • Answer validation with regular expressions (regex) to make sure the information collected follows a specific format. For example, when gathering details such as official document numbers, contact IDs, tax numbers, IBANs, or any data that must meet formatting requirements.
    Answer validation is available for the following question types:
    • Long Text
    • Short Text
    • Email

Answer validation is available on all Typeform plans, except Typeform legacy plans.

Answer validation for Long and Short Text

1. Open a form and click + Add content.

2. Select Long Text or Short Text.

3. Write your question, and optionally, add a description.

4. If you want to set a maximum of characters for answers, toggle on Max characters and manually set a character limit.

5. Toggle on Answer validation and enter a regular expression (regex). 

In the example below, we’re asking for an employee ID, and we want to make sure that the information provided is in a valid format of eight numbers and two uppercase letters.

To get a specific validation pattern, simply ask for it in the Typeform AI chat. 

Copy and paste the regex pattern into the Answer validation field.

You can test the regex pattern in preview mode by clicking the play button in the tool bar.

If a respondent enters an employee ID 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.

Screenshot 2026-03-27 at 11.43.50.png

When you're done editing your form, click the Share/Publish edits button to make it live.

Answer validation for Email

The Email question type verifies that responses follow a valid email format (e.g. xxxx@yyy.zzz) by default. You can also use Answer validation to enforce additional patterns or specific formatting.

You can use Answer validation to accept specific email domains. However, you can't add lookahead regex patterns to reject specific email domains. 

For example, you can't add regex patterns to reject gmail.com, icloud.com, and yahoo.com email domains but you can add a regex pattern to only accept typeform.com email addresses. 

We're currently working on removing this limitation of rejecting non-work email addresses and the ability to apply other regex based validation rules to the Email question type.

1. Open a form and click + Add content.

2. Select Email.

3. Enter the text for your Email question and optionally, add a description.

4. Toggle on Answer validation and enter a regular expression (regex).

In the example below, we're asking for a work email address from a specific company (Typeform) and we want to make sure employees are entering their Typeform work email address.

To get a validation pattern for a specific domain, you can ask Typeform AI in the chat. Below, we ask for a regex pattern to only accept the typeform.com email domain.

Copy and paste the regex pattern into the Answer validation field.

You can test the regex pattern in preview mode by clicking the play button in the tool bar.

If a respondent enters an email that doesn't match your validation pattern, they'll see an error message and won't be able to continue until their answer is in a valid format.

When you're done editing your form, click the Share/Publish edits button to make it live.

Common validation pattern examples

Some of the common validation pattern examples are the following:

Validation type Regex pattern
US zip code ^\d{5}(-\d{4})?$
UK postcode ^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$
Spanish postal code ^(0[1-9]|[1-4]\d|5[0-2])\d{3}$
Hex color ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Uppercase only ^[A-Z\s]+$
US Passport Number ^[A-Z]?\d{8,9}$
California driving license ^[A-Z]\d{7}$ (1 letter + 7 digits)
Alphanumeric (3-10 characters) ^[A-Za-z0-9]{3,10}$

Pattern Complexity

Complex patterns can impact form performance. Below you'll find some best practices for patterns.

Do:

  • Keep patterns simple and efficient
  • Use anchors (^ and $) to match the entire string
  • Be specific with character classes (e.g. used [a-z] instead of .)
  • Use bounded quantifiers (e.g. {2,5}) when possible
  • Test patterns thoroughly before publishing the form
  • Provide clear field descriptions explaining the expected format

Example pattern: ^\d{3}-\d{4}$

This regex pattern is very specific, and it checks for the following:

  • The start of the string with ^ 
  • Exactly 3 digits with \d{3} 
  • A literal hyphen with -  
  • Exactly 4 digits with \d{4}
  • The end of the string with $

You can validate the following examples with this pattern:

  • 123-4567 
  • 000-0000


Don't:

  • Don't use nested quantifiers (e.g. (a+)+)
  • Don't use backreferences (e.g. (\w+)\1)
  • Don't use overly complex patterns with many alternations
  • Don't rely on lookahead/lookbehind assertions
  • Don't use unbounded matching with .* on large inputs

Example pattern: `^(\d+|\w+|[a-z]+|[A-Z]+|[0-9]+)*$`

This regex pattern is overly complex. It's redundant and checks for any combination of letters, digits, or underscores.

You'll encounter an invalid pattern error if you try adding a validation pattern like this one to the Answer validation field in your form.

Group 889.png

Was this article helpful?

Have more questions? Submit a request

Tap into our community knowledge

Find answers

Can’t find what you’re looking for?

Contact support