Limit number of characters in single/multiline text fields

Hi there, 

How can I limit the number of characters in a single line and multi-line text field? From past posts, I understand this can be done with JavaScript code pasted in the field's description, but it is not working. 

Running JIRA v 7.4. Any help would be greatly appreciated. 

 

Thanks, 

James 

1 answer

0 votes

Hi James,

I found that I could restrict the input with a script such as

<script type="text/javascript"> document.getElementById("customfield_10203").maxLength=8; </script>

Which can limit the editing of a field to only 8 characters.  I was able to do this in my Jira 7.5.0. instance.

However this only appears to work when you click the Edit button for the issue.  If your Jira instance is setup to use the inline edit feature, it looks like changing the value this way does not honor this imposed limitation.

 

However I don't really like using javascript in this way.  Mostly because this only effects users in the web gui.  With Jira, it is also possible that issues could be created via the REST API, which in turn would not be effected at all by this java script work-around.  Because of that, I was trying to see if there was another way around this that could check for both conditions.

I found an interesting related post in https://community.atlassian.com/t5/Jira-questions/Trying-to-limit-the-number-of-characters-in-a-text-field-single/qaq-p/364908

In that post @Adrian Vital  purposed using a workflow validator in order to check the length of a field using a regex.  This might be helpful in order to make sure that an issue cannot transition until this field is corrected with an appropriate value.  But the workflow validator only prevents transitions, it does not directly effect what value can be entered in that issue at any other given time.

I hope this helps,

Andy

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,965 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot