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!

0 vote
Renjith Pillai Community Champion Jan 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)

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,305 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot