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

Text Box Conditional Formatting

New Here ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Hi,

 

I'm trying to set up a javascript that will change the fill color of a textbox depending on what value is currently present in said textbox. The value is auto calculated using the sum of other fields in the form and ranges from 0 - 250. Is it possible to make the text box change its fill color to (for example) green if the values is less than 30, yellow if it is between 30-50, and red if it is greater than 50? It would also be helpful if the text in the text box was still a black colored font. 

 

Thank you for all your help!

TOPICS
JavaScript , PDF forms

Views

718

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
Community Expert ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Use this as validation script:

if(event.value == "")
event.target.fillColor = color.white;
else if(event.value < 30)
event.target.fillColor = color.green;
else if(event.value >= 30 && event.value <= 50)
event.target.fillColor = color.yellow;
else if(event.value > 50)
event.target.fillColor = color.red;

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
New Here ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Thank you so much for getting back to me! I'm pretty much a knuclehead when it comes to javascript, so I'm having some trouble getting this validation script to run correctly (I'm copying and pasting from your message into the JavaScript Editor). 

 

Whenever I copy/paste and click "OK", the script no longer appears in "Run customer validation script:" field in the validate menu. Are there additional steps I need to be taking?

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
Community Expert ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

LATEST

You are not first person today that say that can't paste code into editor, so I'm not sure if it's something with the forum or something else.Try first paste code into notepad or some text editor and then copy from notepad into javascript editor in acrobat or try input code manually.

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