How to set rules for your form

You can create rules that people have to follow when they fill out your form. For example, if you ask for email addresses, you can make sure that people can only submit properly formatted email addresses.

Set up rules for a question

  1. Open a form in Google Forms.
  2. Click Add .
  3. To the right of the question title, choose the type of question. Learn more about types of questions.
  4. To set up rules, click More More.
  5. Click Response validation.
  6. To set up a rule select first the type of rule you want. The rule options available depend on the type of question chosen.
  7. Optional:  To add an error message, on the right, in the “Custom error text” field, enter an error message. Responders will get this message when their answer doesn’t follow the rules.
  • Example: You reached the limit of 200 words.

Types of rules

Each question type has different settings options.

Rules for short answer questions
  • Number: To ensure the answer contains a certain number, in the drop down menu, select Number. Then, select one of the options for your rule.
  • Examples:
    • A number greater than or equal to 50
    • A number between 21 and 42
  • Text: To ensure the answer contains certain text, in the drop down menu, select Text. Then, select one of the options for your rule:
    • Example: Make sure that answers contain the word "candy.”
  • Length: To set up a maximum or minimum character count for your answer, in the drop down menu, select Length. Then, select Maximum or Minimum character count, and the number.
    • Example: Limit answers to 500 characters or require at least 200 characters.
  • Regular expression: To require text answers to match certain formulas that you choose, select Regular expression. Then select one of the options in the drop down menu (Contains, Doesn’t contain, Matches, Doesn’t Match) and add the pattern. Learn more about regular expressions.
    • Example: Response must be a 10-digit phone number, where the range for each digit is 0–9.
      • Input: Regular expression Matches [0–9]{10} 
      • Expected result: 1234567890
Rules for Paragraph questions
  • Length: To set up a maximum or minimum character count for your answer,  in the drop down menu, select Length. Then, select Maximum or Minimum character count, and the number.
    • Example: Limit answers to 200 characters.
  • Regular expression: To require text answers to match certain formulas that you choose, select Regular expression. Then select one of the options in the drop down menu (Contains, Doesn’t contain, Matches, Doesn’t Match) and add the pattern. Learn more about regular expressions.
  • Example: Response must be a 10-digit phone number, where the range for each digit is 0–9.
    • Input: Regular expression Matches [0-9]{10}
    • Expected result: 1234567890
Rules for checkboxes questions
  • Select at least: Set a minimum number of boxes that can be checked.
  • Select at most: Set a maximum number of boxes that can be checked.
  • Select exactly: Specify the number of boxes that must be checked.
Rules for Multiple choice grid questions

In multiple choice grid questions responders can only choose one column per row.

To set up your question:

  1. In Google Form, click Add .
  2. Add your question to the “Question” field.
  3. To the right of the question title, choose Multiple choice grid .
  4. Add the options for the rows. For example: A, B, C.
  5. Add the options for the columns. For example: 1, 2, 3.

To custom your question you can setup these options:

  • To make sure responders choose an option from each column, turn on “Require a response in each row.” If they don’t, they get an error message and can’t continue. See how to set up an error message.
  • To limit answers to one choice per column:
    1. At the bottom right, click More .
    2. Check the box next to “Limit to one response per column.”
  • To shuffle the row order every time the survey is open:
    1. At the bottom right, click More .
    2. Check the box next to “Shuffle row order.”

Example of “Limit to one response per column”

Input:

  • Rows: A, B, C
  • Columns: 1, 2, 3

Result: Responders can choose one row item (A, B, C) for each column (1, 2, 3). If they check multiple rows in a column, they get an error message.

Rules for Checkbox grid questions

In multiple choice grid questions responders can only choose one column per row.

To set up your question:

  1. In Google Form, click Add .
  2. Add your question to the “Question” field.
  3. To the right of the question title, choose Checkbox grid .
  4. Add the options for the rows. For example: A, B, C.
  5. Add the options for the columns. For example: 1, 2, 3.

To custom your question you can set up these options:

  • To make sure responders choose an option from each column, turn on Require a response in each row. If they don’t, they get an error message and can’t continue. See how to set up an error message.
  • To limit answers to one choice per column:
    1. At the bottom right, click More .
    2. Check the box next to “Limit to one response per column.”
  • To shuffle the row order every time the survey is open:
    1. At the bottom right, click More .
    2. Check the box next to “Shuffle row order.”

Example of “Limit to one response per column”

Input:

  • Rows: A, B, C
  • Columns: 1, 2, 3

Result: Responders can choose one row item (A, B, C) for each column (1, 2, 3). If they check multiple rows in a column, they get an error message.

Regular expressions

You can require answers to match a particular set of criteria called regular expressions. Regular expressions search for patterns in the answers.

Examples of regular expressions

Important: If you search for instances of a character that has a specific meaning in regular expressions, you should place a backslash in front of the character when you enter your search. For example, if you want to search for an instance of the $ character, you should enter: \$.

This table shows some of the expressions that Google Docs supports. There are many other supported expressions you can use.

Expression Description Example Matches Does not match
. A period signifies any character in the given position. d. do, dog, dg, ads fog, jog
* An asterisk after a character signifies a search for that preceding character repeated zero or more times. do*g dog, dg, dooog dOg, doug
+ A plus after a character signifies a search for that character displayed one or more times. do+g dog, dooog dg, dOg, doug
? The previous expression is optional. do?g dg, dog dOg, doug
^ A caret must be placed at the beginning of a regular expression and signifies that the string starts with the character(s) or sequence placed after the caret. ^[dh]og dog, hog A dog, his hog
$ A dollar sign must be placed at the end of a regular expression and signifies that the string ends with the character(s) or sequence placed before the dollar sign. [dh]og$ dog, hog, hot dog dogs, hog, doggy
{A, B} The previous expression is repeated between A and B times, where A and B are numbers. d(o{1,2})g dog, doog dg, dooog, dOg
[x], [xa], [xa5] A character set indicates that just one of the given character(s) should occur in the current position. For the most part, any characters are valid within brackets, including characters mentioned previously in expressions: [xa,$5Gg.] d[ou]g dog, dug dg, dOg, dooog
[a-z] A character set range signifies a search for a character within the given range of characters. Common ranges include a-z, A-Z, and 0–9. Ranges can be combined into a single range: [a-zA-Z0-9]. Ranges can also be combined with character sets (mentioned previously): [a-zA-Z,&*]. d[o-u]g dog, dug, dpg, drg dg, dOg, dag
[^a-fDEF] A character set beginning with a ^ signifies a search for a character that isn't within the given set. d[^aeu]g dog, dOg, dig, d$g dg, dag, deg, dug
\s Any white space character. d\sg d g, d[TAB]g dg, dog, doug

Below are a couple of examples of how regular expressions could be used to search a spreadsheet:

  • Search for cells that contain dollar amounts

    • Enter the following in the Find bar: ^\$([0-9,]+)?[.][0-9]+

This means a dollar amount where the first number is any number 0–9 or comma occurring zero or more times, followed by [.], followed by any number 0–9 repeated one or more times. This search would return any of the following: $4.666, $17.86, $7.76, $.54, $900,001.00, $523,877,231.56

  • Search for cells that contain US zip codes

    • In the “Find” bar, enter: [0-9]{5}(-[0-9]{4})?

This means a U.S. zip code consisting of five numbers with an optional hyphen and four-digit add-on.

  • Search for cells containing names beginning with a lowercase letter

    • Enter the following into the Find bar: ^[a-z].*

This means a cell input that contains a lowercase letter followed by another character 0 or more times. This search would return any of the following: bob, jim, gEORGE, marTin

Related resources

true
Visit the Learning Center

Using Google products, like Google Docs, at work or school? Try powerful tips, tutorials, and templates. Learn to work on Office files without installing Office, create dynamic project plans and team calendars, auto-organize your inbox, and more.

Search
Clear search
Close search
Google apps
Main menu
1461342052822487080
true
Search Help Center
true
true
true
true
true
35
false
false