Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,971
Community Members
 
Community Events
165
Community Groups

Add placeholder/hint text into custom field using JavaScript not working

I went to find certain community questions about add placeholder text or hint text into custom field, and found that the answer is to use JavaScript like:

<script type="text/javascript">
document.getElementsByName('customfield_10700')[0].placeholder='This will appear as a placeholder';
</script>

place into custom field's description, but it didn't work at all like below:

Capture.PNG

It displayed at below the field instead of display inside the field.

Any suggest solutions to add placeholder/hint text into field?

1 answer

1 accepted

0 votes
Answer accepted
Florian PEREZ Community Leader Jun 12, 2022

Hello, 

The method you suggest is not available on cloud, only on server and DC. 

If you want to achieve this you'll have to use context for this specific field and add a default value. While this is not perfect because it fill the field with a real value you don't want to keep you can also try thid other way:

Adding the 'hint' into the description of the custom field, by adding the as a specific field configuration.

Alternatively (but less clean) you can add this information into abother field (the show only field).

Hope this help! 

Hi,

I noticed that the different between cloud and Server/DC, as I checked from my site, is it considered as Server/DC?

Capture.PNG

Sorry if I choose wrong hosting type.

Thanks.

That seems like DC.

 

Do you have 'Enable HTML in field descriptions and list item values' enabled in General configuration (/secure/admin/ViewApplicationProperties.jspa)?

Nope, it was disabled, should I need to enable it?

That depends on your team and if your (global) Jira administrators can be trusted, since at the end of the day, running any javascript with authenticated users could be a serious problem.

I mean I suppose we're talking XSS scripting effectively (https://owasp.org/www-community/attacks/xss/).

In general I would say enabling this is fine, but you should probably decide that on your own.

I see, what if the field is user picker field, is it able to display placeholder text into it?

I try to enable 'Enable HTML in field descriptions and list item values' and the normal text field able to show the placeholder/hint text in the field, but unable to show for user picker field.

Florian PEREZ Community Leader Jun 14, 2022

It could be a limitation, but TBH you should try to avoid adding text into a field not supposed to manage text. 

hope this helps

Thanks for all your responses and answers.

I had a discussion with our team and we decided not to enable the 'Enable HTML in field descriptions and list item values' as will impact other application.

So we will put the hint text below the field instead of inside the field as placeholder.

Once again thanks for the discussion and I'll accept this as answer.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you