How to add validation for date entries on form fields on the portal?
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Jira Forms doesn't validate date/time according to a date range. The good news is that we do have the following feature request that suggests having such functionality:
In case this feature is of your interest, we encourage you to watch and vote for it, so that request increases visibility to our Product team, and also you can receive the latest updates from our Development team. If you have further feedback about this request, we encourage you to comment on the feature request.
This article can serve as a workaround until the feature is implemented.
Environment
Jira Service Management Cloud, Forms
Solution
You achieve something similar by linking the Form date field to any of your Date picker Jira fields, for example:
Then, on the "Settings" tab, associate the form to an existent request type:
Depending on the Request type associated with your Form, you'll need to add a validator to the issue-type workflow based on the request type used.
1) Go to Project settings > Workflows > Edit the correspondent issue type workflow > Select the diagram mode > select the "Create" transition > Validators. For example:
2) On the next page, click on "Add validator" and choose the Date Compare validator, then fill in the following information:
- Date: select the linked Jira field used on your Form.
- Condition: Select Compare with: (Choose Expression) and input 2w value
- Click on Save
That's it now whenever a user raises a request of the selected request type tied up to your Jira Form, the date validator won't let users continue until the day selected matches within the 2-week date criteria, they will see an error when the date doesn't match the validation: