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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.