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

Accepted Answer
1 vote

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

21,896 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