Hi,
We want to set some default text to custom field on issue creation page, as soon as user click on custom field input box default value should be clear and user has to enter new value. Is it possible with javascript/jquery?. If yes kindly provide some help on it with sample code.
Community moderators have prevented the ability to post new answers.
Hi Jonson!
Sure you can. Please see here: https://confluence.atlassian.com/display/JIRA/Configuring+a+Custom+Field#ConfiguringaCustomField-default_valueDefaultvalue
========
If you need the suggestion text that disappears when you start typing, you can try to inject placeholder attribute via jQuery. Please add following JavaScript to the Description of your custom field:
$document.ready(function() { $("YOUR-SELCTOR").attr("placeholder", "Type here to search"); });
Instructions how to do it: https://confluence.atlassian.com/display/JIRAKB/How+to+display+a+Field+based+on+another+Field%27s+selection
I was thinking the same, but the tricky part is to clear the field as soon as you click in that field. I have no solution for that and I'm curious if there is!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr, You are suggestion is valid, but it does not work as we expected. If we set default value for field as you suggested above, it set value for field permanently. This is we are not looking. We are looking for suggestion predefined text in custom fields and when user click in that field we would like to cleat that text and if not we have not set any value in that custom field. For example, please refer below example. Same we are expecting in JIRA. Is it possible. http://www.dailycoding.com/Uploads/2008/08/DefaultTextSample.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jonson, please see updated answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for quick response on it Volodymyr. I have few queries on above java script: $document.ready(function() { $("YOUR-SELCTOR").attr("placeholder", "Type here to search"); }); Here , YOUR-SELCTOR -------------> is my custom field name. But what is the "place holder" attribure here ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
YOUR-SELCTOR is jQuery selector: https://api.jquery.com/category/selectors/ "placeholder" is HTML attribute so do not touch it: http://www.w3schools.com/tags/att_input_placeholder.asp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried to do as mentioned above but the description text appears with the jQuery supplied instead of the text alone appearing within the custom field text box which should disappear on clicking the field.
Eg: A custom field 'Sponsors' was added with the description text as below:
Once the field was added to the JIRA issue, the Description text appears as below:
Could we get the description text to appear within the 'Sponsors' field and to disappear when we click on this field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm seeing the same problem as Jen: the "Edit Custom Field Details" form does exactly what is says it does: display what's entered underneath the field, verbatim.
Has the the support for customising the text using jQuery deteriorated since 2015 (when the question was raised)? The suggested solution has an element of XSS attack about it, so i would not be surprised that a general improvement in security stopped the solution from working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.