How can I set the size of custom field "Text Field" from javascript in jira?

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2013

Can I set the size of custom field "Text Field (< 255 characters)" to 50 Chars from javascript in jira?

5 answers

1 accepted

1 vote
Answer accepted
Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2013

In the field description, add this

<script type="text/javascript">

document.getElementById("customfield_xxxxxx").maxLength=50;

</script>

where
customfield_xxxxxx is the id of your
Text Field

JoeR July 24, 2013

When I try the code above nothing happens. Only difference is I'm checking a field length of 5.

I guess I'll try a Script Runner transition, but why doesn't the javascript fire?

If I put an alert in the javascript, an alert pops up on the screen right when I hit save. Why would that happen, I haven't entered and data yet!

Faisal Shamim November 8, 2019

This didnt work me , i am using Jira cloud , How will it work there?

0 votes
Hung Nguyen June 17, 2021

I came across this and follow the following instruction for JIRA Server :

https://confluence.atlassian.com/jirakb/how-to-change-text-box-length-on-a-screen-ui-in-jira-732399321.html

I used the following css for the field Environment for ex:

#environment-val /* The "id" of the "Environment" text box */
{
margin: -2px 0 0 -5px;
width: 100%;
}
0 votes
Jagadeesha Jayaramaiah April 7, 2013

Hi,

I have a similar requirement that, i have to set the width of the customefield(Number field). But, using the above javascript in the field description does not serve the purpose.

Please help with the same

Regards,

Akshatha

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2013

That's work fine for me in v5.1 jira.

0 votes
Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2013

In the field description, add this

<script type="text/javascript">

document.getElementById("customfield_xxxxxx").maxLength=50;

</script>

where
customfield_xxxxxx is the id of your
Text Field

0 votes
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2013

Or simply add a validator using Script Runner, rather than doing it in javascript (which can break anytime, and it is just a client side validation)

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2013

Thanks!

But, how can i achieve that? I need complete guide to that.

Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2013

Suggest an answer

Log in or Sign up to answer