How to use regex to set validation for a number input on a form field

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Summary


The minimum and maximum field attributes designed in the number type field in Jira forms take into account the number of digits and not the numerical values. If you add the minimum as 3 then the values accepted are 111, 121, 133 etc.

This article explains how you create a field to input a number within a specific range or a specific format using regex validation.

Environment

Jira Service Management Cloud

Diagnosis

The number field defines the minimum and maximum number of digits and not values. Additionally, there is no option to add an additional validator or an error message.


Output:



Solution

You can use a short text or long text field to input the number value. Furthermore, use regex to limit the range or if you like the format in a specific pattern. Additionally, you can add an error message to be displayed for wrong values added.

So for 1-8 numbers try ^[0-9]{1,8}$ and you can even specify an error message.


Reference Article: Regex validation 

Last modified on Jan 23, 2025

Was this helpful?

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