Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Changing font of specific text within a caption

Avatar

Level 3

Is there a way to specify only certain text within a caption to be changed by an event script?

I have an audit script that runs when users try to sign their form.  It identifies errors and lists them on the signature page if any are found.  It also highlights the errors with red text on the form.  But sometimes, in order to identify the specific error, I only want part of a caption to have its text turned red.

Is there a way, for instance by specifying the character positions, to identify specifically which text within a caption should be modified by an event script?

Thanks,

Emily

1 Reply

Avatar

Level 10

You can only change the color for the entire Caption but not a part of it.

The below code can help alter the caption for the TextField1.

xfa.resolveNode("TextField1.caption.value.#text").value  = "This is Test Caption";
TextField1.caption.font.size = "20pt";
TextField1.caption.font.fill.color.value = "150,125,120";

Alternative Approach:

If you want only to have a part of the caption to be "Red", you can use the Text Object (Not Text Field) to hold the value and remove the Caption form the TextField.

If your captions are static means if you know the text for the caption at the design time itself, place multiple Text Objects on your form for the caption.

One with default Black and then one for Red etc..

If you place them next to each other it look like a single caption to the user.

But this gives control on which text Object text you can change to Red or Black color.

Thanks

Srini