How to I control what can be entered into specific field types?

I'm trying to control a field type so that only numeric characters (no alpha, punctuation, or spaces) can be entered.

I have looked into controlling field behaviour many times, and read through the different field types but have not been able to find what I need.

Is there some sort of qualifier I can set? Or is there a plug-in that adds a "number only" field option?

Any suggestions or directions would be much appreciated!

1 answer

1 accepted

1 vote
Accepted answer

There's a simple "number" custom field type - if you use that, the users won't be able to commit anything other than numbers.

You could also find/write a plugin (or use the script runner) to provide a validator that can check the input as well, if the simple number field isn't clever enough for you.

I had tried that, but it allows for spacing and some punctuation. I don't suppose you could point me in a good direction for finding JIRA field plug-ins?

Thanks! I'll have a browse.

I'd have a rummage through

If you can't spot anything easy there, then I'd reach for some coding - however, if you look for the Scripting Plugin at , that would save you having to write a whole plugin (I'm not 100% sure it can do it, only about 97%)

Sorry I couldn't point at any specific one - I've found the number field to be good enough (when I've accessed the data in plugins, it comes out as a number, so I'm not sure why you're getting spaces or punctuation being allowed in it)

No worries. I appreciate any suggestions.
I tried again with the number field and I was unable to use spacing. (this may have been fixed when we updated a month or so ago; I dont believe I had tried again since.) But specifically we are looking to display a cell phone or contact number. The problem arises because people put these in all sorts of formats (123-456-7890, (123) 456 7890, etc) which makes searching not as accurate (we have to type all the potential formats that could have been used, right?). When using a number field it allows for "." because it considers it a decimal and then auto shortens to two decimal places. As well, it adds the commas - which can be confusing for new hires (if you might know of a way to disable the comma display that would help).

Ah, I see. Problem here is that 'phone numbers are not numbers, they're strings. Numbers allow for decimal points and don't have leading 0s.

I'm English, we use a . to indicate the decimal places and , to break up numbers - e.g. 1,000.56. Jira lets you customise your separators (it takes a guess from your language), but it's global, so if you change it to make phone numbers look better, you'll break real numbers.

I think the answer here is some form of regex validator if you want to brute-force it, but I'd actually be very tempted to write a "telephone number" field plugin - one that would let users enter their random formats, with some more sensible restrictions (no letters) but provide a "searcher" that ignores the separators both in what the users type in to search for, and the data in the field.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,517 views 15 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you