Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Need to use regex validation on Scriptrunner for a field validation


Hello all.

I have a text field called "initial value" and I need to implement a scriptrunner validator on this field while creating an issue on Jira Service Desk.

The value within this field must only be a number between 0 and 10,000 (0 <= N <= 10000)

I have tried the following script but, although it throw no errors, the validation is nor working properly.


! cfValues['Initial Value'] || cfValues['Initial Value'] ==~ /\d([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|10000)/

Can anybody throw some light into this?

Thank you!! 

2 answers

1 accepted

2 votes
Answer accepted

Hi @Luiz Gregorio ,

Is there any particular reason for using a regex and not an if statement? In any case, you could use:

# true from 0 to 10k


Kind regards,

Hi Rafael, not any particular reason, in fact I am not an expert on scripts, I found this solution online.

I have tested using your regex condition and it worked like a charm.

If anyone needs this, the correct line would be:


! cfValues['Initial Value'] || cfValues['Initial Value'] ==~ /^(10000|([0-9]{0,4}))$/

Thank you for your help

I have a text field and would like to allow only number in the format of "#.#.#" and each # accepts a max of 3 digits".

I have configured something like this.



It works fine with numbers but it is allowing users to enter all the special characters. Can you please help me with regex condition excluding the special characters. 

Hi @Dinesh ,

(dot) . Matches any character except linebreaks.

Please, try the following:

import java.util.regex.Pattern;
import org.apache.log4j.Level;

private boolean isValid(String value) {
final String REGEX = /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/;

final Pattern PATTERN = Pattern.compile(REGEX);

return PATTERN.matcher(value).matches();

0 votes

Hi @Luiz Gregorio ,

I think there are two kinds of script runner validates. Are you using the simple one? Otherwise you must throw an exception if the validator should prevent someone of creating an issue (InvalidInputException, I think ,but can not check this currently)

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events