Validating custom date time field

Marco Scicluna January 14, 2025

How can I create a validation in the Create screen to restrict users to enter a time between 09:00 and 17:00. I wish to prompt the user if the input is outside of this time window and the issue is not created.

Thank you.

1 answer

0 votes
Robert DaSilva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2025

Hi @Marco Scicluna , this should be possible with the "Regular Expression Check" validator available in Jira Cloud by default.

 

This will require you to use a plain text custom field, and a regular expression that reflects the range you're looking to validate.

This regex should work, but please confirm with your own testing:

(([9]|1[0-6])\:[0-5]{1}[0-9]{1})|(17:00)

To break down the regex, largely it's split into two sections:

(([9]|1[0-6])\:([0-5]{1}[0-9]{1}))

and

|(17:00)

 

The first section has the following goals:

  • The first digits that appear in the string are between 9 and 16
  • Following these digits, there is a : symbol
  • After this :, there are two digits totalling between 00 and 59

The second section has the following goal:

  • The string is exactly 17:00

 

 

You should be able to add this validator to the create transition, and this will prevent the issue from being created if this fails.

 

Hope that helps,

Robert

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2025

@Marco Scicluna @Robert DaSilva - This will validate the date entry, but the user won't receive a prompt that the entry is invalid before the issue is created. 

The easiest way to validate user input before they submit the request is to use a Form rather than the out-of-the-box Request format. You can set the validation regex that @Robert DaSilva suggested in the field on that form. 

Alternatively, you could use an App such as Extension for Jira Service Management or Behaviours - ScriptRunner for Jira Cloud. These will both support pre-submit validators on regular JSM portal screens.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events