Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Limit range of Number Field

Mikkel Kragelund Nielsen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2013

Hey Does anyone know how to limit a number field (Custom field), to a certain range. So it can only be 1-14 ex.

1 answer

1 accepted

1 vote
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2013

try something like this with Javascript

<script type="text/javascript">
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		limitSize();
	});
		limitSize();
	
	function limitSize(){
				
				$('#customfield_13820').keyup(function(e){				
					var decimalValue = $("#customfield_13820").val();
					if(decimalValue < 1 || decimalValue > 14){
						alert("Value should be 1-14");						
						return false;
					}					
			});		
	}	
	
});
</script>

Mikkel Kragelund Nielsen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2013

This dosen't work. What JIRA version are you on. Im on 5.2.9.

I can get the alert message to show if I delete everything else:

<script type="text/javascript">
alert("Value should be 1-14");
</script>
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2013

we are using jira 5.2.5,

where you have added javascript?

i suggest to add as it by changing custom field id on footer.jsp or load it add webresource in any plugin

Mikkel Kragelund Nielsen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

I have just added it to the description of the field.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2013

field description on field configuration right?

Vinod Honnalli
Contributor
January 27, 2016

The above code is not working.

can anyone suggest the right code??

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events