When creating a form it can really help to limit the types of responses allowed. You can do this by using data validation.
- You can click on the three dots on the bottom right side of your question and select Data Validation.
- Then select Regular Expression, Matches.
- Then insert the example codes below in the Pattern section. Your custom error text can be something like "Must Be Valid Email Address"
1. Postal Address – allow only alphanumeric characters, spaces and few other characters like comma, period and hash symbol in the form input field.
2. ZIP Code – the regex allows ZIP codes in standard formats.
3. Date – accept date input in the mm/dd/yyyy or mm-dd-yyyy formats.
4. Email Address – the regex below should match most common email address formats, including Gmail aliases that accept the “+” sign but there’s no perfect solution
5. URL (Web domain) – this is useful for fields that require the user to enter their website address and it even matches the upcoming TLDs like .directory or .restaurant. The other regex matches YouTube URL including those using the youtu.be domains.
6. Character Limit – the default text box in a Google form allows users to input any number of characters but you can impose a limit with the help of regular expression. Here we limit the input to 140 characters much like Twitter.
7. Phone Numbers – these are often a series of numbers preceded by an optional “+” sign and the area code may be inside brackets.
8. Price (with decimal) – if a form field requires users to enter a price of an item in their own currency, this regex will help. Replace the $ sign with your own currency symbol.
9. Complex Password – only accept a string that has 1 uppercase alphabet, 1 lowercase alphabet, 2 digits and 1 special character. Also the minimum allowed length is 8 characters.
10. CAPTCHA – Google forms do not offer CAPTCHAs but you can create one using regex. Here’s a simple captcha that requires users to answer a simple question – what is 2+2?
11. Word Limit – If you would like to limit the number of words that a user can type in the input field of a Google Form, there’s a regex for that as well. In this case, we only allow any input that has between 10 to 15 words:
Validate answers in your form
Useful Regular Expressions for Validating Input in Google Forms