HTML patterns for US phone numbers and ZIP codes: inputs, failures and limits SimilarForm · Published 2026-12-03 · Updated 2026-12-03 https://www.similarform.com/resources/html-pattern-phone-zip-examples Use explicit US-only phone and ZIP formats, preserve leading zeroes, and test empty values, separators and rejected inputs before publishing your form. These examples check formatting only. A match does not establish that a phone number is assigned or that an address is deliverable. Do not use these US-only patterns for an international audience. Start with visible instructions and the right input type Use tel for the phone field and text for the ZIP field. A ZIP code is an identifier, not a quantity: a number input can discard leading zeroes and does not support the pattern constraint. Add a visible format hint, not just a placeholder that disappears while typing. The phone pattern below accepts ten digits with optional paired parentheses and common separators. It deliberately rejects +1 and extensions. If those are valid for your users, change the documented requirement and retest instead of silently stripping their input.

For example: (415) 555-0132. US numbers only.

Five digits, optionally followed by a hyphen and four digits.

Run this phone-number test matrix Use the validation-pattern generator with the US phone number preset. Try the values below and check the result. The generator tests format; in your actual form, required also determines whether an empty field is allowed. Input | Expected in required field | Why (415) 555-0132 | Accept | Paired parentheses and ten digits 4155550132 | Accept | Ten digits without separators 415.555.0132 | Accept | Dot separators (4155550132 | Reject | Unpaired opening parenthesis 415)5550132 | Reject | Unpaired closing parenthesis +1 415-555-0132 | Reject | Country prefix is outside this stated format 415-555-0132 ext 9 | Reject | Extensions are outside this stated format Empty string | Reject | The field is required Preserve leading zeroes in ZIP codes The ZIP pattern accepts five digits and an optional four-digit extension separated by a hyphen. It does not check a postal database. Keep the value as text in storage and exports so that 02108 does not become 2108. Input | Expected | Reason 02108 | Accept | Leading zero preserved 94107-1234 | Accept | ZIP+4 format 941071234 | Reject | Extension separator missing 9410 | Reject | Too short 94107 | Reject | Trailing space is not part of this pattern Check the native browser form, not only the regex HTML pattern matches the entire non-empty value and uses Unicode-aware regular expression rules. Do not add JavaScript slash delimiters to the attribute. An empty optional input is allowed; required makes an empty answer invalid. Submit a staging form with each test value and inspect the visible error experience using keyboard navigation and a narrow screen. An invalid pattern may fail to apply, and JavaScript submission can bypass native checks. Enforce the same business requirements on the server; browser validation is a convenience for visitors, not a security boundary. Avoid sending a phone number, address or typed test value to analytics. Track only the preset, whether input was a sample or entered by the visitor, and a match/no-match outcome. A successful validation check is more informative than making a visitor spend longer on the page. Phone and ZIP field acceptance checklist Document the audience and acceptance rules before copying a pattern into a form. Countries and formats this form supports: ____________________________________________________________ Accepted samples and why they should pass: ____________________________________________________________ Rejected samples and the error shown: ____________________________________________________________ Empty-field, paste and leading-zero checks: ____________________________________________________________ Server validation and accessibility review: ____________________________________________________________ Sources reviewed 2026-12-03 MDN: HTML pattern attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/pattern MDN: required attribute and missing values: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/required Continue your task Try the validation pattern generator: https://www.similarform.com/tools/validation-pattern-generator Troubleshoot a pattern that is not working: https://www.similarform.com/resources/html-pattern-not-working Sign up: https://www.similarform.com/early-access