Take Control of Your Form Data: How to Prevent Bad Inputs with Regex Validation

Incorrect or inconsistent data entry can slow down workflows, create automation failures, and require manual corrections. Regex Field Validation in Smart Forms for Jira helps enforce structured data input, ensuring that users provide information in the correct format before submitting a form.

This guide walks through how to set up regex validation, where to apply it, and practical regex examples to keep your Jira data clean and usable.j9eyqwsx62c61.jpg


Set Rules for Your Form Fields: How to Use Regex Validation

1. Controlling Text Input and Attachments

When users enter email addresses, IDs, or filenames, incorrect formatting can cause issues later. Regex validation allows you to set clear rules so that only correctly formatted inputs are accepted.

Steps to apply regex validation:

  1. Open the Form Builder in Smart Forms for Jira.
  2. Add or select a Single-Line Text Input or Attachment field.
  3. Go to the Validation section and enable "Must match regex pattern."
  4. Enter a Regex Pattern that defines the expected input format.
  5. Set a custom error message to help users correct mistakes.

Examples of useful regex patterns:

  • Email Format Validation:

    ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
    

    Ensures a valid email format (e.g., user@example.com).

  • Restricting File Uploads to PDFs:

    /\.pdf$/i
    

    Allows only PDF file uploads.

You can also set minimum and maximum character limits for text fields.

Default error messages:

  • "Must be at least [min] characters."
  • "Must be at most [max] characters."

2. Controlling Selection-Based Fields (Multi-Choice & Checkboxes)

For fields where users select multiple options, you can prevent too many or too few choices.

Steps to apply validation:

  1. Select a Multi-Choice or Checkbox field in the Form Builder.
  2. Define minimum and maximum number of choices.
  3. Add a custom error message when users exceed the allowed selections.

Default error messages:

  • "Select at least [min] options."
  • "You can select up to [max] options."
  • "Your selection must be between [min] and [max] choices."

3. Setting Numeric Limits

For fields that collect prices, IDs, or quantities, setting a minimum and maximum range ensures values remain within acceptable limits.

Steps to apply validation:

  1. Select or add a Numeric Field in the Form Builder.
  2. Set minimum and maximum numbers allowed.
  3. Define error messages for out-of-range values.

Default error messages:

  • "Value must be at least [min]."
  • "Value must be at most [max]."
  • "Value must be between [min] and [max]."

What Happens When a User Enters Invalid Data?

🚫 If the input doesn’t match the regex pattern, the form will:

  • Display the custom error message set for the field.
  • Prevent submission until the issue is fixed.
  • Guide users toward the correct input format.

Common Regex Patterns for Error-Free Forms

1. Enforce Proper Email Formatting

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

✅ Ensures users enter a properly formatted email (e.g., user@example.com).


2. Validate International Phone Numbers

^\+?[1-9]\d{1,14}$

✅ Supports E.164 international phone number format (e.g., +1234567890).


3. Format US Phone Numbers Correctly

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

✅ Accepts US phone numbers with or without separators (e.g., (123) 456-7890).


4. Restrict ZIP Code Formatting

^\d{5}(-\d{4})?$

✅ Matches 5-digit ZIP codes with an optional 4-digit extension (e.g., 12345 or 12345-6789).


5. Ensure Jira Issue Key Formatting (e.g., PROJECT-123)

^[A-Z]+-\d+$

✅ Ensures inputs follow Jira issue key format (e.g., DEV-123).


6. Standardize Invoice Numbers

^INV-\d{6}$

✅ Ensures a consistent invoice numbering format (e.g., INV-202345).


7. Enforce US Social Security Number (SSN) Format

^\d{3}-\d{2}-\d{4}$

✅ Matches SSN format (e.g., 123-45-6789).


8. Validate Tax ID Number (TIN)

^\d{2}-\d{7}$

✅ Ensures Tax ID formatting compliance (e.g., 12-3456789).

Key Takeaways for Using Regex Validation in Smart Forms for Jira

  • Regex validation ensures structured data input and prevents errors.
  • Validation rules can be applied to text, numeric, multi-choice, and checkbox fields to enforce specific formats.
  • Custom error messages help users correct their inputs before submission.
  • Regex patterns allow you to define complex input formats, ensuring data accuracy.

By implementing Regex Field Validation effectively, teams can reduce errors, improve automation workflows, and maintain cleaner data in Jira.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events