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 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...

27,207 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