Skip to main content
All CollectionsBuild & customizeField types
How to set customized validation on form fields (RegEx)
How to set customized validation on form fields (RegEx)

Ensure data accuracy with custom validation rules. Use Regular Expressions (RegEx), control input format, character types, and quantity.

Updated over 9 months ago

The custom validation field lets you define what input is valid to be inserted.

This field has a “Validation rule” property you can set to specify what’s valid and what’s not. The Validation Rule follows the Regular Expression (or RegEx) rules.

🗄️ Old dashboard:

In the old dashboard, you can use and add the 'Custom validation' field from the edit tab and add the validation rule and the description from the left menu.

Restrict input to start/end with something

To restrict your field to accepting input that starts with a specific value, you can use the ^ character at the beginning of that specific value. For example, to accept words that start with “dog” put ^dog as your Validation Rule.

To have your audience enter values that end with a specific value, you can use the $ character at the end of that specific value. As an example, to accept values that end with “dog” put dog$ as your Validation Rule.

Now let’s mix and match! If you set ^cute dog$ as your Validation Rule, it will accept input that starts with and ends with “cute dog”. And I mean the exact match, nothing else.

Accept input that includes a specific text

Simple! Put that text into the Validation Rule property. It will match any input that has that text in it.

Make sure a specific number of characters are inserted

Quantifiers help you with that. For example, 003* matches an input that has 00 followed by zero or more 3‘s. While 003+ matches inputs that have 00 followed by at least one 3 (one or more 3‘s).

And 003? makes sure the input contains 00 followed by zero or one 3.

Also, 003{5} matches inputs that contain 00 followed by exactly five 3‘s.

Make sure the exact order of value is inserted

To make sure the order of characters in the inserted value is exact, you can use parentheses. For example, a(bc)* as your Validation Rule, makes sure the inserted value has an a followed by zero or more copies of the sequence bc.

Use “OR” to set a variation of the Validation Rule

It gets more interesting when you know you can set different variations on your custom validation field. You can use | as the OR sign and add multiple rules in between. For example, Hi|Hello matches an input that has either Hi or Hello in it.

For example, (b|cd)ef accepts values that have either bef or cdef in them.

When you want to accept any single character

A period character (.) stands for any single character. For example, a.[0-9] matches inserted values that have an a followed by one character and a single digit number between zero and nine.

Also, ^.{3}$ accepts input values with exactly 3 characters.

Specify which characters or numbers are allowed

You can use brackets for that purpose. As an example, [ab] matches any input that has either an a or a b (works the same as a|b). Also, [a-d] matches values that have lowercase letters ‘a‘ through ‘d‘. (works the same as a|b|c|d and even [abcd]).

Let’s mix and match to see what we can do so far!

^[a-zA-Z] makes sure that the inserted value starts with a letter.

[0-9]% accepts the inserted value only if it has a single-digit number before a percent sign.

,[a-zA-Z 0- 9]$ matches with input values that end in a comma followed by a letter or a number.

Specify how many digits to have: For example an 8-digit code

You can use a range quantifier {min, max} to specify a minimum of 1 digit and a maximum of 8 digits as:

^[0-9]{1,8}$

Explanation:

^ : Start anchor [0-9] : Character class to match one of the 10 digits {1,6} : Range quantifier. Minimum 1 repetition and maximum 6. $ : End anchor

Test it out!

To make sure your custom validation is working as expected, you should test it for yourself and see how your changes are working. Go to your Formaloo dashboard now and add a custom validation field to try it out. You can also use this RegEx pattern tester to test and see what values your validation rule accepts. It will automatically highlight the matches it finds in the textbox below.

Check out and pick this template for the most requested custom validations. You can get an idea of how you can customize your forms’ validations using it.

🧩 Template:

This Custom Validation Template is a useful tool for ensuring that the information entered into your forms is accurate and in the correct format.

This template features pre-designed fields that guide users to input information accurately, including email addresses, phone numbers, and dates.

Did this answer your question?