Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How do I set the font weight for part of the text in a text field

Avatar

Former Community Member
LiveCycle Designer: 8.1



HI,



I am able to set the font weight for a particular TextField value in my form as follows.



xfa.resolveNode("Message.Message.OfferLetter.OfferLetterHeader.CustomerName").font.weight = "bold";



My question is, is it possible to set the font weight for part of a TextField value?



e.g. "Username: Some UserName", where "Username:" is set to bold weight and "Some UserName" is normal weight.



The text "Username: Some UserName" is currently bound to the TextField Value from a source XML file and I cannot easily separate the source XML (so that I could bind part of the XML to the TextField Caption and part to the TextFiel Value)



Regards



James
2 Replies

Avatar

Former Community Member
I answered my own question regarding this with the following code



1. Set the TextField value to a variable strChar

2. Based on the indexOf value of strChar "UserName: Some UseName" which is 9.

3. Separate the first 9 chars using a Left javascript function and assign the to a variable strLeftChar = "UserName"

4. Separate the remainig chars using a Right javascript function and assign the to a variable strLRightChar = "Some UserName"

5. Then do the following:



//Make the caption visible

pricingNodes.item(i).caption.presence = "visible"

//Set the text field caption text equal to strLeft

pricingNodes.item(i).caption.value.text.value = strLeft;

//set the text field value text equal to strRight

pricingNodes.item(i).rawValue = " " + strRight;

//set the caption font weight equal to bold

pricingNodes.item(i).caption.font.weight = "bold";



Not that neat as a solution, but it does the job if this helps anyone.

Avatar

Level 6
Another way would be to use a rich text field (i.e. a text field with the field format set to "Rich Text". I don't have the code handy, but I know that it's possible to programatically manipulate the rich text in such a field.



Jared