Skip to main content
MaksDad07
Inspiring
February 28, 2019
Answered

Changing formatting based on filed value

  • February 28, 2019
  • 1 reply
  • 636 views

I want to change the formatting of a value entered into a field based on that value.  i.e. if value greater than 5, the value will appear bold and in red (6).

Thank you in advance for your help. 

This topic has been closed for replies.
Correct answer try67

Enter this code as the field's custom validation script:

if (Number(event.value)>5) {

    event.target.textFont = font.HelvB;

    event.target.textColor = color.red;

} else {

    event.target.textFont = font.Helv;

    event.target.textColor = color.black;

}

I used Helvetica as the font. If you want to use another one you'll need to find out the name of the regular version and of the bold version of that font, as Acrobat doesn't have a "bold" setting, like Word does. I also assumed that you want the text to be black if the value is less than (or equal to) 5, although you didn't specify that in your question.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 28, 2019

Enter this code as the field's custom validation script:

if (Number(event.value)>5) {

    event.target.textFont = font.HelvB;

    event.target.textColor = color.red;

} else {

    event.target.textFont = font.Helv;

    event.target.textColor = color.black;

}

I used Helvetica as the font. If you want to use another one you'll need to find out the name of the regular version and of the bold version of that font, as Acrobat doesn't have a "bold" setting, like Word does. I also assumed that you want the text to be black if the value is less than (or equal to) 5, although you didn't specify that in your question.