Using Workflow 'Regular Expression Check' Validator to Restrict Text Field in Number Format

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

Comma(s) will be automatically added for every 3 digits in NUMBER FIELD. This is not making sense if we use number field for Phone Number, Postcode and etc. A suggestion ticket was raised to improve this at JRA-7582.

Prerequisites

Resolution

  1. Create the custom field (eg: Phone Number) in *Text Field (Single Line)* and add them to the corresponding screens
  2. Use Workflow's validator to make sure only numbers can be entered for these fields
    1. Go to Project Setting > Workflows
    2. Edit the workflow for the affected issue type
    3. Switch to Diagram mode
    4. On Create transition, click on the Validators
    5. Choose Add Validator > Regular Expression Check
      1. Field to validate: <Field created in Step 1>
      2. Regular expression:

        ^[0-9]*$

        Regular Expression for Other Scenarios

        If you would like to restrict the field to a specific length: 

        ^[0-9]{n}$


        If you would like to allow it to empty:

        ^[0-9]{0-n}$


        If the field is required:

        ^[0-9]{m-n}$

        n refers to the maximum number of the length

        m refers to the minimum number of the length

Alternative Solution

For customers who don't have the JSU - Suite Utilities for Jira installed, the plugin Unique Regex Custom Field provides a free alternative which allows you to create custom fields with a build-in regular expression check.


Last modified on Sep 3, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.