• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changing formatting based on filed value

Explorer ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

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. 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

354

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 28, 2019 Feb 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

...

Votes

Translate

Translate
Community Expert ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines