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!
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'd have a rummage through https://marketplace.atlassian.com/search?q=validator
If you can't spot anything easy there, then I'd reach for some coding - however, if you look for the Scripting Plugin at https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner , that would save you having to write a whole plugin (I'm not 100% sure it can do it, only about 97%)
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.
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot