Adding Custom Format Validation to a Survey Question
Any survey question that collects free text can have a validation pattern attached. Instead of accepting anything the visitor types, the question checks that the answer matches an expected shape — a phone number, an order number, a ZIP code, whatever the question is actually asking for — and rejects an obviously wrong answer before the survey submits.
You do not need to know regex to use this. Most formats you'd ever need are available as a ready-made preset you just pick from a list. Regex is only needed for a genuinely custom format none of the presets cover.
Setting it up
- Open the question in the survey editor.
- Under Validation, open the Validation preset list.
- Pick the preset that matches what you're collecting. Common presets include:
| Preset | Example |
|---|---|
| Phone (US) | 555-867-5309 |
| Phone (International) | +44 7911 123456 |
| Email Address | jane@acme.com |
| URL / Website | https://acme.com |
| ZIP Code (US) | 90210 |
| Postal Code (Canada) | K1A 0B1 |
| Postcode (UK) | SW1A 1AA |
| Currency (USD) | $1,250.00 |
| Number Only | 42 |
| Date (MM/DD/YYYY) | 03/15/2026 |
| Order / Reference Number | ORD-10042 |
(Additional presets cover letters-only, alphanumeric, integer-only, and a few other common formats.)
- If nothing fits, choose Custom Regex at the bottom of the list, then enter your own pattern in the Validation pattern field that appears.
- Optionally set a Validation message — the exact wording shown to the visitor if their answer doesn't match (e.g. "Please enter your order number, like ORD-10042"). Leave it blank to use a sensible default message for the preset you picked.
- Save the question.
Validation runs live as the visitor answers, so a bad format is caught at the point of entry — no follow-up cleanup needed after the fact.
What validation does and doesn't check
A validation pattern only checks the shape of the answer — does it look like a phone number, an order number, a ZIP code — matching the pattern character-by-character. It does not confirm the value is real, current, or exists anywhere:
- A correctly-formatted phone number can still be disconnected.
- A correctly-formatted order number can still not exist in your system.
- A correctly-formatted email address can still not belong to anyone.
Use validation to catch obviously wrong input at the point it's collected — a typo, a missing digit, a name typed into a phone field — not as a substitute for checking the value against your own system afterward.
Writing your own pattern (Custom Regex)
If you do need a custom pattern, keep it simple and specific to the shape you expect, rather than trying to also verify the value is correct. A pattern that's too strict will reject legitimate answers you didn't anticipate (extra spaces, a different but valid separator); a pattern that's too loose won't catch much. When in doubt, start from the closest built-in preset and adjust it rather than writing one from scratch.
Related reading
- Using the Phone Number Question Type — a dedicated question type with built-in phone validation and no setup required, for the common case of just collecting a phone number.
- Surveys in Velaro — the full survey question-type reference.
- Custom Fields Guide — the same preset/custom-regex validation approach, applied to contact and conversation custom fields instead of survey questions.
Was this article helpful?