If you want to require alphanumeric characters in a form response, you can use a format mask and a simple regular expression (regex) string to match your required pattern.
⭐ Get Inspired
This article was adapted from a post by Technolutions staff in the Slate Community Forums' Get Inspired space. Have a great idea for a Get Inspired post? Let us know!
Before you begin
This article assumes basic familiarity with regex syntax.
To add a format mask to a form field, select Edit Field on the field and enter the value in Format Mask.
If you need a broader introduction to format masks, start with Format Mask in Forms.
Test every regex pattern thoroughly before using it in production.
Example: match the word Slate
The examples below show progressively stricter ways to match the word Slate in a text field.
Match Slate anywhere in the value
Use this format mask:
/Slate/This pattern matches any value that contains the exact text Slate.
Examples that match:
SlateMy Slate account
Examples that do not match:
slateSLATE
Use this when capitalization must remain exact and the value can contain other text before or after the word.
Match Slate or slate
Use this format mask:
/[Ss]late/[Ss] tells the regex engine to match either uppercase S or lowercase s.
Examples that match:
Slateslateusing slate today
Examples that do not match:
SLATEsLATE
Use this when the value may contain other text, but you want to allow only these two common capitalizations of the word.
Match Slate or slate as a standalone word
Use this format mask:
/\\b[Ss]late\\b/\\b marks a word boundary. This prevents the pattern from matching Slate as part of a longer word.
Examples that match:
SlateslateSlate!Welcome to Slate today
Examples that do not match:
slatesslatework
Use this when the word must appear on its own, even if other text is also present in the field.
Match only Slate or slate
Use this format mask:
/^[Ss]late$/^ anchors the pattern to the beginning of the value, and $ anchors it to the end. Together, they require the full value to match the pattern.
Examples that match:
Slateslate
Examples that do not match:
Slate!My Slate accountslates
Use this when the field should accept only the single word Slate or slate, with no additional characters.
Match only Slate, slate, Slate!, or slate!
Use this format mask:
/^[Ss]late(?:[!]|$)$/This pattern still requires the full value to match from beginning to end, but it also allows an exclamation point at the end.
Examples that match:
SlateslateSlate!slate!
Examples that do not match:
Slate?My Slate!slates
Use this when you want to allow a very specific punctuation variation without accepting other trailing characters.
Choose the right boundary
Use \\b when the word can appear inside a longer sentence but still needs to stand on its own.
Use ^ and $ when the entire field value must match the pattern.
Validate the result
After adding a regex format mask:
Test values that should pass.
Test values that should fail.
Check variations in capitalization, punctuation, and spacing.
Remember that changing a format mask does not automatically reformat existing saved values. Existing data updates when the tab is edited and resaved.
When regex may not be the best tool
Regex works well for text-pattern validation, but it is not always the simplest solution.
If the requirement depends on other fields, multiple conditions, or business logic, consider using calculation formulas or submission conditions instead.