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

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

4 answers

1 accepted

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

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!

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)

Thanks!

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

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

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

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

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 yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

162 views 4 8
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