Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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();


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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

479 views 5 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you