Plain text - single line - validated format fields use regex to determine how your bookers can answer a booking form field. A regex (regular expression) is a sequence of characters which defines a valid input.

For instance, a regex could determine that a booking form field asking for a booker’s telephone number can only be successfully completed if no characters other than numbers are entered. Further, it could ensure that only telephone numbers with 11 digits are accepted.

By design, regex can prevent your bookers from completing a booking form field, and therefore a booking, if their data entry does not match the format you have defined. It is essential that you understand exactly what your regex expression calls for, and that this is also communicated to your bookers.

Regex is only recommended for those who are confident in its use, or who have had problems with incorrectly entered data in the past. Our support team are always happy to discuss your requirements and answer any questions you may have.

Before you get started

Validated format fields are only available by request. If you would like to use them please contact our support team (via our website chat, or email) to turn them on.

Creating a validated format field

Validated format fields are created via Setup - Booking fields, by selecting 'plain text - single line - validated format' from the Field data type drop-down menu (general guidance on creating booking form fields can be found here).

You should see a Validator field, which is where you enter your regex.

Typically, regex code begins with '/' and ends with '/g' but our validated format fields incorporate these characters so you only need to enter the characters that are contained within '/' and '/g' when defining your validation.

It's recommended to include some explanation of the form validation in the additional help text field and/or the example input (placeholder) field to help your bookers understand what is required to successfully complete the field. In addition, you may wish to include a contact email address/telephone number so that people can reach out to you directly if they are unable to complete the field.

As an example, if I was collecting a 10 digit registration number, I could include the following instructions for my bookers:

Additional help text: Please check to ensure that you enter your 10 digit registration number. Numbers with fewer or greater than 10 digits cannot be accepted. Contact support@bookwhen.com if you are unable to complete.

Example input (placeholder): 1234567890

Creating a regex

Regex is a powerful tool that has many applications, this help article will cover a few useful expressions and basic functions. Any validation formats not covered below could be possible, please contact us via our website chat or by email for help with putting together other expressions.

Here are some commonly used regex codes:

^[0-9]*$

Only numbers will be accepted in the field.

Example valid inputs: 123456789, 123, 0000, 7

Example invalid inputs: 12345678a, 123.4, abcd, @

^[a-zA-Z0-9]*$

Any sequence of alphanumeric characters without spaces will be accepted.

Example valid inputs: a1b2c3d4, aaaaa, 12345, Ab12CD34

Example invalid inputs: a1b2 c3d4, a.a.a.a., £12345, A bcde

^[a-zA-Z0-9 ]*$

As above, but spaces are permitted

Example valid inputs: a BCDe, 123456, ABC 123, 000 999

Example invalid inputs: a/b/c/d, 123.456, ABC @123, 999!

Regex can also be used to determine the number of characters which must be inputted for a valid response. This could be a specific number or a range of numbers. Just replace * with these brackets { }, containing your desired character number (or number range).

For example,

^[a-zA-Z0-9]{8}$ indicates that only alphanumeric inputs (with no spaces) that are exactly 8 characters long are valid

^[a-z0-9]{7,10}$ is the same as above only it permits inputs of 7, 8, 9, or 10 characters and doesn't allow upper case characters.

You can find further advice on putting together regex expressions here.

Testing regex

It is strongly recommended that you test all regex expressions here before implementing validated booking form fields. This will help you to ensure that the expressions are validating according to your requirements.

Did this answer your question?