With Voxel v1.5.4 release, they allow us to format the text field using regex. Here are some example of how to use it.
Pattern: Enter a regular expression that all submitted values must match. Here are some simple examples.
Only letters: [A-Za-z]+
5-digit ZIP code: \d{5}
Phone number (e.g., 123-456-7890): \d{3}-\d{3}-\d{4}
\(\d{3}\) \d{3}-\d{4}
Expected Output: This will format the phone number to look like (xxx) xxx-xxxx
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Expected Output: Validates email formats like [email protected]
.
^\d{3}-\d{2}-\d{4}$
Expected Output: Matches US Social Security Numbers in the format 123-45-6789
.
^(\d{1,3}\.){3}\d{1,3}$
Expected Output: Validates IPv4 addresses, like 192.168.1.1
.
^(https?:\/\/)?(www\.)?[a-z0-9-]+\.[a-z]{2,}(/.*)?$
Expected Output: Matches URLs with optional http
or https
, optional www.
, followed by the domain name and optional path. Examples: http://example.com
, https://www.example.com/page
.
^\d{4}-\d{2}-\d{2}$
Expected Output: Validates dates in the ISO format, like 2023-12-31
.
^(?:4[0-9]{12}(?:[0-9]{3})? # Visa
| 5[1-5][0-9]{14} # MasterCard
| 3[47][0-9]{13} # American Express
| 3(?:0[0-5]|[68][0-9])[0-9]{11} # Diners Club
| 6(?:011|5[0-9]{2})[0-9]{12} # Discover
| (?:2131|1800|35\d{3})\d{11})$ # JCB
Expected Output: Validates major credit card numbers including Visa, MasterCard, American Express, Diners Club, Discover, and JCB.
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
Expected Output: Matches hexadecimal color codes, like #FFFFFF
, #FFF
, FFFFFF
, or FFF
.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Expected Output: Ensures passwords have a minimum of 8 characters, including at least one uppercase letter, one lowercase letter, one number, and one special character (@$!%*?&
).
^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$
Expected Output: Validates domain names adhering to typical domain standards, like example.com
or subdomain.example.com
.
^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$
Expected Output: Matches UK mobile phone numbers, like +44 7400 123456
, 07400 123456
, or (07400) 123 456
.
^(\+61\s?4|\(?04\)?)[ -]?(\d{4})[ -]?(\d{4})$
Expected Output: Matches Australian mobile numbers typically starting with 04
, such as +61 4 1234 5678
or 0412 345 678
.