Limit range of Number Field

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

Accepted Answer
1 vote

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>

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>

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

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

field description on field configuration right?

The above code is not working.

can anyone suggest the right code??

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

21,939 views 2 7
Join discussion

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