Change the color of a label field

RudhraKAM
Tera Guru

Hi

How do we change the color of a label field on catalog item and service portal 

 

We have  a label name u_test  which has a question" this is test "

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Do you want the color when form loads?

if yes then use onLoad client script

Ensure Isolate Script is set to false for this client script; this field is not on form but from list you can make it false

function onLoad(){

var getLblParent= g_form.getElement('u_test').id.replace('sys_original.','');

var getLblElement = $j("label[for='"+getLblParent+"']").css('color','red');


}

find_real_file.png

Isolate Script: False

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

13 REPLIES 13

RudhraKAM
Tera Guru

Ankur : your script is working perfect , couple of quick questions

can we increase the size of the text ?

Can we set only some part of the text Red ? ie "This is Test " just Test in red color

Use below code in client script to change font and color of label

 

var getLblParent= g_form.getElement('label_test').id.replace('sys_original.','');

 

var getLblElement = jQuery("label[for='"+getLblParent+"']").css('color','red');

 

Rgards,

Sachin

Thanks Sachin ,, that part is working as Ankur posted but is it possible to 

can we increase the size of the text ?

Can we set only some part of the text Red ? ie "This is Test " just Test in red color

Hi Kam,

Refer below link for increase the size of the text.

https://community.servicenow.com/community?id=community_question&sys_id=467d4fe9db9cdbc01dcaf3231f96...

 

If it helps then please mark my answer Correct and Helpful.

Vishakha