Skip to main content
Limit who can and cannot signup for your subscription with custom form field validations. The Firmhouse payment page has some general rules in place to verify that your customers fill in all the required fields correctly, like an email address. Depending on your offering, it’s possible you do not want everyone to be able to sign up. You might want to filter subscribers to meet your specific criteria, for example, when you only deliver your product in a specific geographic region.

What are Custom Form Field Validations?

With custom form field validations you can define specific requirements for new customers. These validations check if the data entered by the customer are within the criteria you allowed. For instance area codes, whether a phone number is mobile, etc. During signup we will automatically verify this for you.
Please note: This is an advanced feature powered by Regular expressions (regex), so it may seem a little complicated to set up if you have not worked with regular expressions before. We will walk you through some examples in this article so you can create your own rules too. If you need further help, do not hesitate to reach out to our customer support.
This feature can be accessed via the Checkout menu, Extra fields and Validations submenu on the left. Here you can Create, Edit and Delete a custom form field validation.
Custom Form Field Validation

Creating a New Validation

1. Select a Form Field

You can create a validation for any core field of the Firmhouse checkout page form:
  • Zipcode
  • Email
  • Phone Number
  • City
  • Address
  • House Number

2. Write a Regular Expression

Write a pattern that the user’s input should match against. We support 3 regular expression options that you might need for more advanced patterns:
  • i - ignore case
  • x - ignore whitespace in the regular expression
  • m - make dot match newlines in the regular expression
You can select multiple options or skip it if you do not need any of them.

3. Add an Error Message

Write some error text to let your users know why they cannot sign up to your subscription. You can create multiple validations for the same field and we will show error messages accordingly.

4. Test Your Regular Expression

We added a playground so you can test your regex when you are creating one. Go to the Playground section and enter some value you want to test and you will see if it is valid or not right away. For example, the regex ^12345$ will match the value 12345 but will not match the value 12347.
Regex Playground

Example Regular Expressions for Core Form Fields

Zipcode

To match a few zipcodes, one of the options is to add your selected zipcodes in the following format:
^(12345|12346|12347|23467)$
This creates a hard limitation to only allow these numbers.
TIP: When building a regular expression, start your regex with ^, end it with $, and split values with |.
  • ^ means the start of the string, so no additional characters are allowed before your value (12345 is allowed, 112345 is not)
  • $ means the end of the string, so no additional characters are allowed after your value (12345 is allowed, 123451 is not)
To match a big range of numbers you can create a smarter regex:
^(120[3-5][0-9][0-9])$
This will cover all the numbers in the range 120300 - 120599. Country-specific zipcode patterns: For the United States:
^\b\d{5}\b(?:[- ]{1}\d{4})?$
This allows values in the format “NNNNN” or optionally “NNNNN-NNNN” where N is any number. For The Netherlands:
^\d{4}\s{0,1}[A-Za-z]{2}$
This allows values in the format “NNNN AA” where N is any number and AA are letters. For The United Kingdom:
^[A-Za-z]{1,2}\\d([A-Za-z]|\\d)\\d[A-Za-z]{2}$
This allows values in the format “A(A)N(A/N)NAA” where N is any number, A is a letter, and optional characters are in parentheses. For China:
^\d{6}$
This allows values in the format “NNNNNN” where N is any number.

Email

You might want to only allow users with emails at a particular domain name:
^.+@example.com$
  • . (dot) means any character
  • + (plus) means any amount of times
With this pattern, any amount of characters (more than 0) is allowed before “@example.com”.

Phone Number

You might need to allow users to register only with country-specific phone numbers. For example, US numbers with formats (123)123-1234 and 123-123-1234:
^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$

City

If you want to limit your delivery area to specific cities, you can set up a simple regex. For example, to allow only users from Amsterdam and Rotterdam:
^(Amsterdam|Rotterdam)$

Address

If you want your customers to write their address from a specific address list:
^(Green street|Main street)$
To make your regex case insensitive (to allow both “Green street”, “green street” and “Green Street”), select the “ignore case” option when creating your validation. If you want your customers to write their address in a specific format:
^[a-zA-Z]+, \d+$
This will only allow addresses in the format: any amount of case-insensitive letter-characters (more than 0) followed by a comma, followed by a space, followed by any amount of digits.

House Number

If you want to limit your delivery area to specific house numbers:
^(11|15)$
This will allow only users with house number 11 or 15 to sign up.
^(11-15)$
This will allow only users with house numbers in the range between 11 and 15 (inclusive) to sign up.