Form Field Validation Settings (coming soon)
Overview
The Regex Field Validation allow form creators to enforce input rules for different form elements. These rules help maintain data accuracy, prevent errors, and guide users by displaying helpful validation messages.
Using Regex Validation for Smart Forms
Setting Up Validation Rules
1. For Single-Line Text Input and Attachment Fields
Navigate to Form Builder:
Open the form builder in Smart Forms for Jira.
Add or select a Single-Line Text Input or Attachment field.
Enable Regex Validation:
Under the Validation section, check the box "Must match regex pattern".
Enter Regex Pattern:
Input a valid regex pattern in the Regex pattern field.
Examples:
Email:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
PDF file format (for attachments):
/\.pdf$/i
For text input fields, you can set Minimum characters and Maximum characters limits.
Input Validation Rules:
Minimum Characters:
No min characters
Maximum Characters:
No max characters
Default Error Messages:
Must be more than or equal to [min] characters.
Must be less than or equal to [max] characters.
Define Error Message:
Provide a custom error message in the Regex error message field.
Example:
Invalid email format. Please use "example@domain.com".
2. Configuring Validation for Multi-Choice and Checkbox Fields
Select Multi-Choice or Checkbox Field:
In the form builder, choose a Multi-Choice or Checkbox field.
Set Minimum and Maximum Choices:
Define Minimum number of choices and Maximum number of choices.
Leave blank or enter "No min choices" and "No max choices" for unlimited selections.
Error Message Configuration:
Default messages include:
Must be more than or equal to [min] choices.
Must be less than or equal to [max] choices.
Must be between [min] and [max] choices.
3. Adding Validation for Numeric Fields
Select Numeric Field:
Add or select a Numeric field in your form.
Define Numeric Range:
Enter values in Minimum number and Maximum number fields.
Leave blank or enter "No min number" and "No max number" if no limits are required.
Error Message Configuration:
Default messages:
Must be more than or equal to [min].
Must be less than or equal to [max].
Must be between [min] and [max].
FAQs
Q1. What happens if a user input doesn't match the regex pattern?
The field will show the custom error message you defined, prompting the user to correct their input.
Q2. Can I use regex validation for optional fields?
Yes, regex validation applies only when the user fills out the field.
Q3. Are regex patterns case-sensitive?
By default, regex patterns are case-sensitive. To make them case-insensitive, use the i
flag (e.g., /pattern/i
).
Examles for Regex validation rules
1. Email Address
Regex:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Example Input:
user@example.com
Description: Ensures the input is a valid email address.
2. Phone Number (International)
Regex:
^\+?[1-9]\d{1,14}$
Example Input:
+1234567890
Description: Validates international phone numbers using the E.164 format.
3. Phone Number (US Format)
Regex:
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
Example Input:
(123) 456-7890
Description: Accepts US phone numbers with optional separators like dashes, dots, or spaces.
4. ZIP Code (US)
Regex:
^\d{5}(-\d{4})?$
Example Input:
12345
or12345-6789
Description: Matches standard US ZIP codes with an optional four-digit extension.
5. Jira Issue Key Validation (Project-123 format)
Regex:
^[A-Z]+-\d+$
Example Input:
DEV-123
Use Case: Ensures that input follows the Jira issue key format used in bug tracking and project management.
6. Invoice Number (Finance Teams)
Regex:
^INV-\d{6}$
Example Input:
INV-202345
Use Case: Ensures invoice numbers follow a standardized format.
7. National ID / Social Security Number (US)
Regex:
^\d{3}-\d{2}-\d{4}$
Example Input:
123-45-6789
Use Case: Validates social security numbers for compliance.
8. Tax ID Number (TIN)
Regex:
^\d{2}-\d{7}$
Example Input:
12-3456789
Use Case: Ensures tax IDs are formatted correctly.