Using the DOM property rawValue on a XFA text field does not allow the setting of rich text.
Use a XHTML envelope and add your marked-up text through exData.loadXML()
Text fields in XFA forms have a limited support for XHTML markup, allowing rich text text fields in a fillable form.
You can populate these fields using JavaScript, but it requires a bit more trickery than a simple call to field.rawValue
Here's a script that sets the value of a text field to contain styled text - so long as the text field has its property set to Rich Text
// This is the envelope that the HTML-formatted data needs to be placed in
// remember to escape quote marks
var envel = '<?xml version="1.0" encoding="UTF-8"?><exData contentType="text/html" xmlns="http://www.xfa.org/schema/xfa-template/2.8/"><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acroform:2.7.0.0" xfa:spec="2.1"><p> PLACEHOLDER</p></body></exData>';
// This is the HTML-formatted data
var jsdata = '<b>Hello</b> <i>Stylish</i> <u>World</u>';
// put the HTML data in the envelope
jsdata = envel.replace(/ PLACEHOLDER/g,jsdata);
// Load the XHTML into the field
// the ..., 1, 1 arguments are required for exData to understand the content it seems...
form1.sub1.TextField1.value.exData.loadXML(jsdata, 1, 1);
To extract the HTML afterwards, you will need to use "saveXML". To get just the resulting plain text, you can access via rawValue as normal.
+