Validation rules ensure that contacts enter the correct type of data in your Act-On forms. For more control of your validation rules, define a custom rule using a regular expression (regex). This lets you enforce specific formatting rules — perfect for situations where the built-in validation options aren’t enough.
Common Use Cases for Regex Validation
-
✅ Match ID formats:
Require specific patterns, such as employee IDs or promo codes.^EMP-\d{4}$(Matches: EMP-1234 & EMP-5678, but not EPM-1234, EMP-A234, or EMP-12345) -
🔢 Limit input length:
Control field length for usernames, codes, or postal entries.^\d{5}$(Exactly five digits for ZIP codes, such as 97204) -
🔡 Accept only letters and spaces:
Prevent entries with numbers or symbols in name fields.^[A-Za-z\s]+$(Allows: John Smith, but not JSmith42) -
📧 Restrict by email domain:
Ensure only work or partner emails are accepted.^[a-zA-Z0-9._%+-]+@yourcompany\.com$(Only allows @yourcompany.com addresses) -
🔒 Allow only specific email addresses:
Useful for test forms or internal events.^(john@example\.com|jane@example\.com)$(Allows only these two addresses)
This regex can be extended to be a larger list of emails.
Need Help Writing a Regex Pattern?
Tools like ChatGPT can help you build one by describing what you want to allow or block, like “only allow Gmail addresses” or “match a ZIP+4 code.”
You can paste the result into the Custom Rule field in your form.
Include a Clear Error Message
When a contact submits a form that doesn’t match your rule, they’ll see an inline error message. Be sure to write a message that clearly explains what’s expected.
Example error messages:
“Please enter a valid employee ID (example format: EMP-1234)”
“Only company emails are allowed (example: jane@yourcompany.com)”
Add a Custom Validation Rule
- Open your form in the Act-On Forms Composer
- Select the field you want to validate
- In the right panel, in the Validation section, click
-
From the drop-down, select Custom:
- Paste your regex pattern into the box on the right.
- Under Error Messages, add a clear error message, as described above.
- At the bottom right, click OK, & at the top right, Save your changes.
- Test your form to check that the validation works as expected. Learn more
Tips and Best Practices
- Keep custom regex rules simple and well-documented
- Always include a clear error message for your users
- Test your form to check that the validation works as expected. Learn more