← Back to all guides
Technology · 3 min READ

How to Validate a Five-Digit ZIP Code in Google Forms

How to Validate a Five-Digit ZIP Code in Google Forms guide illustration

Add a five-digit U.S. ZIP code rule that accepts leading zeros. Test common errors and adapt the pattern if you also accept ZIP+4.

Quick note

Follow these steps at your own pace. Check product terms and prices directly with providers before purchasing.

Quick answer

Add a Short answer question. Open its three-dot menu, choose Response validation → Regular expression → Matches, and enter ^[0-9]{5}$. This accepts exactly five digits, including a leading zero as in 02108.

Set up the question

  1. Label the question U.S. ZIP code. If you also collect international addresses, route respondents to a country-specific section before asking for postal codes.
  2. Choose Short answer. Open the question’s More menu at the lower right and add the validation rule. Paste the pattern without spaces, quotation marks, or backticks.
  3. In the custom error field, write “Enter five digits, including any leading zero. Example: 02108.” Turn on Required if a blank answer must also be blocked.

Try these entries in Preview

EntryExpected resultWhat it checks
02108PassA leading zero is allowed.
2108FailFour digits are too few.
0210AFailLetters are excluded.
02108-1234FailThe five-digit rule excludes the extended suffix.
BlankFail only if Required is onValidation and required status are separate settings.

If ZIP+4 is also welcome

Keep Matches and use ^[0-9]{5}(-[0-9]{4})?$. Change the help text to “Enter 02108 or 02108-1234.” Test both examples and try 02108-12 to confirm that a partial suffix fails. The rule checks the format. It cannot confirm that a ZIP code exists or belongs to a particular street address.

Check the value where you use it

If you send responses to a spreadsheet, submit a test through a published copy and inspect the leading-zero example in the destination. If Sheets displays 2108, inspect the cell format and the underlying value before exporting a mailing list. Keep a ZIP code as text in downstream imports when all five characters must survive.

Google Forms Help on regular expressions and response validation

SHARE THIS GUIDE

Know someone who could use this?

DISCUSSION

Comments

Comments are reviewed before they become public.

No approved comments yet. Be the first to start the discussion.