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

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.
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 in02108.
Set up the question
- 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.
- 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.
- 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
| Entry | Expected result | What it checks |
|---|---|---|
| 02108 | Pass | A leading zero is allowed. |
| 2108 | Fail | Four digits are too few. |
| 0210A | Fail | Letters are excluded. |
| 02108-1234 | Fail | The five-digit rule excludes the extended suffix. |
| Blank | Fail only if Required is on | Validation 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
Comments
Comments are reviewed before they become public.
Sign in with Google to leave a comment.
Sign in with GoogleNo approved comments yet. Be the first to start the discussion.