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 vote

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

110 views 0 5
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