In GatedContent.com custom validation rules can be added to fields in the manage fields area. 

Each validation rule must take the form of a valid regular expression.


In this example, we will demonstrate how to block specific email domains.



To get started open the email field and click "Add a validator".


You will then need to choose a name for your custom validator, the regular expression used to execute it, and an error message that will be displayed when it is triggered.


Here is an example of a regular expression you could use to block specific email domains: 


.+@(?!example1\.|example2\.|example3\.)


The domains are added in this section: example1. example2.  and example3. Importantly, these must be pipe separated, and each period must be preceded by a backslash. This will also match any TLD variant, for example, example1.co.uk or example1.com would both be blocked by this regular expression.


Here is the same regular expression with common personal email domains which you can adapt as necessary for your purposes:


.+@(?!gmail\.|hotmail\.|me\.|ymail\.|yahoo\.|mac\.|live\.|me\.|msn\.|outlook\.)



Regular expression validators should always be tested in preview mode before publishing them to ensure they work as intended and don't inadvertently prevent all form submissions.


In addition, care should be taken to specify a meaningful error message that explains to the user exactly what they need to do to pass validation. For example:


"Please enter a business email address"


Is much better than:


"Email address not valid"


Here is an example of how this would look to the end user: