Use the Format field option to make sure users provide information in the right format. This can range from phone numbers to postal codes to serial numbers, and much more! Below, you will find information on how to customize the format of a Single Line Text field and Phone Number field.
Please note: If the format option is left empty in a Single Line Text field, no extra validation will be applied. If the format field is left empty in a Phone Number field, the field will be validated to make sure a valid phone number has been entered.
Set a format with an input mask
You may use the format option to require a specific format and simultaneously apply an input mask. An input mask helps your users enter the correct format, as shown below:
How to set a specific format
Determine the format that will be accepted by following the directions below.
- Go into a Single Line Text or Phone Number field's options.
- Type the preferred format in the Format box.
- Save your form and preview it. When you put your cursor into the field, you will see the input mask appear. Users will only be able to enter characters that fit the saved format.
Accepted characters
The following characters can be used in the Format settings:
- 9 - requires any numeric character
- a - requires any alphabetic character
- * - this is a wildcard; allows any character
- ? - makes the following characters optional
Examples
- Require a phone number in the (999)999-9999 format.
(999)999-9999
- Require a properly formatted social.
999-99-9999
- Require 5-6 numbers.
99999?9
- Require 4 alphabetic characters followed by any character.
aaaa*
Regular expression validation
If the standard format options don't offer the flexibility that you need, use a regular expression to completely customize the format validation. Insert a regular expression beginning with ^ in the Format box. Please note that this will not add an input mask to your field. It will simply make sure the entered values match the format in your regular expression. If the entered values don't match the format, an error will appear after the Submit button is clicked.
Syntax
^[Expression body here]$
Please note that both the starting ^ and ending $ are required to treat the format as a regular expression. If you have questions about your regular expression, you can refer to many free regular expression devoted websites.
Regex examples
- Require 5-10 alphanumeric characters.
^([a-zA-Z0-9]{5,10})$
- Require 99.9999.9999 or 99.99999.9999 for the phone number format.
^([0-9]{2}.[0-9]{4,5}.[0-9]{4})$
- Disallow certain characters. The following example will remove a, 1, ", and '.
^([^a1"']+)$
- Only allow alphabetic characters.
^([a-zA-Z]+)$
- Allow 1-3 characters country code and 2-3 characters area code to create an international phone number format, e.g. Switzerland (+41-83-333-3333)
^(\+[0-9]{1,3}-[0-9]{2,3}-[0-9]{3}-[0-9]{4})$
- Disallow a certain word. The following example will exclude the word mini.
^((?!mini).)*$