Making custom field text red?

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

How to make custom field text red?

<script type="text/javascript">
AJS.$("#customfield_11329").attr('style', 'color:red')
</script>

Above code does not work. Any ideas?

3 answers

1 accepted

2 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

In that way it does't work on 5+ jira version, try with this

&lt;script type="text/javascript"&gt;
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {		
		callFunction();
	});
		callFunction();
	function callFunction(){  		AJS.$('label[for=customfield_11329]').css({color:'red'});
	}
});
&lt;/script&gt;

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

Great. It works!!

But only in edit screen, not in view screen.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

glad to hear it worked!!

if it to be work on view screen you need to check custom field id on view screen

if my answer helped then vote up and accept as answerd :)

Dan27 November 6, 2018

hello @RambanamP ,

Is there any idea how can I do it for edit too?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

@Dan27 the above script will work on edit screen too, just you need to replace customfield id(you can get field id by inspecting element)

Dan27 November 6, 2018

Thank you
@RambanamP,

This text has no id.. only "title" , and it id inside div that has id.. How can I write it in your code?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2018

@Dan27 can you share html content of a customfield on edit screen?

1 vote
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

try with this

AJS.$('label[for=customfield_11329]').css({'color':'red'});
or
AJS.$("#customfield_11329").parent('label').css('color','red');


Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

Does not work!!!

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

<script type="text/javascript">
AJS.$("#customfield_11329").parent('label').css('color','red');
</script>

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

how you tried and whatis the jira version?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

can you share your code? i tried now it is working

Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2013

It is 5.1.5 version,

Still not working

Joe Moreno September 29, 2015

@Rambanam Prasad In which file do I need to edit this?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2015

@Joe Moreno you no need to edit any files, just add code in accepted Answer in Announcement banner for testing, once it worked as expected then i suggest to add this code as web resource module in a plugin(you will get lot of post on this forum if you need to know how to add it in plugin) Note: don't forgot to change customfield id :)

KL Kumar June 29, 2018

@RambanamP I have similar requirement where I need to change the mandatory field labels in Red. But here I am using ScriptRunner Behavior script and it is not working. Here is my code snippet.

// requiredFields has the list of mandatory fields labels.

for(String field in requiredFields){
field = field.trim()
log.warn("Field ::"+field)

String js = "<script type=\"text/javascript\">\n"+
"jQuery(document).ready(function(\$) {\n"+
"JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {\n"+
"callFunction();\n"+
"});\n"+
"callFunction();\n"+
"function callFunction(){\n"+
"AJS.\$('label[for="+field+"]').css({color:'red'});\n"+
"}\n"+
"});\n"+
"</script>"

log.warn(js)
def FormField f = getFieldByName(field)
f.setLabel(js)

Any help is highly appreciated.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2018
<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
callFunction();
});

callFunction();

function callFunction(){
AJS.$('label[for=customfield_11329]').css({color:'red'});
}
});
</script>

add above code on announcement banner by changing cusotmfield id

 

am not sure how to include javascript using behavior. 

KL Kumar July 3, 2018

@RambanamP Thank you. This works well for custom fields. Can this be possible for system fields? I want to show system fields also in Red.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2018

yes, just you need to change replace customfield id with system field id

 

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
callFunction();
});

callFunction();

function callFunction(){
AJS.$('label[for=summary]').css({color:'red'});
AJS.$('label[for=components]').css({color:'red'});

}
});
</script>
KL Kumar July 11, 2018

@RambanamP Thank you!

It works...

Mani September 1, 2018

@RambanamP  I have tried your script and its working fine. 

I have a custom field with "*" at the end of the label.  Is it possible to make only the "*" in Red color instead of whole text?

 

Thanks in Advance.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2018

@Mani you need to try something like follows if you want to add red asterisk, if you have already asterisk and want to make red color then use CSS to make it red 

AJS.$("#customfield_11300").parent().children('label').append('<span class="aui-icon icon-required"></span>');
Like alex likes this
Bunty September 5, 2018

@RambanamP,

Thanks for your reply!

The script is working fine but custom field(version Picker(multiple versions) text is not changing to red color. Need total text to be in red color.

version.PNG

Tried with below script

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
callFunction();
});

callFunction();

function callFunction(){
AJS.$('label[for=customfield_11329]').css({color:'red'});
}
});
</script
Bunty September 6, 2018

@RambanamP

Any help?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2018

can you share the HTML content for the custom field?

Bunty September 7, 2018

Hi @RambanamP,

 I don't see any option to get HTML content. It's a Version Picker(multiple version) custom field not default one.Capture123.PNG

Bunty September 7, 2018

@RambanamP,

HTML content for CMS TestVsersion/s field

<td id="custom-fields-customfield_11110-name">
<strong>CMS Test Version/s</strong>


<div class="secondary-text description">Specify the version(s) on which the defect has been tested.</div>
</td>
<td id="custom-fields-customfield_11110-type" class="nowrap">
Version Picker (multiple versions)
</td>
<td>

Bunty September 18, 2018

@RambanamP

Any help?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2018

is the above code from create/transition screen?

Bunty September 19, 2018

I took HTML content from the web page.

0 votes
MAG-II June 11, 2019

Hi - 

Is it possible to change the color of the field values for system fields? I am hoping to change the values for Labels to red. 

Anyone have any ideas?

Suggest an answer

Log in or Sign up to answer