Skip to main content
October 3, 2019
Answered

How to change the text color in the text field according to the result of <if >

  • October 3, 2019
  • 2 replies
  • 1406 views

I want to change the text color in the text field to red according to the result, but I don't know how.
In the following cases, I want to change the result of "! Over!" to Red color.
I need your advice. Thank you.

 

====

 

var GetNextDAY = this.getField("Next-Birth-DAY").value;
var NextDAY = new Date(GetNextDAY);

var TODAY = new Date();
var HowMany = (NextDAY - TODAY)/24/60/60/1000;

 

if(TODAY > NextDAY){
                                 event.value = ('!Over!');}
                          else{event.value = (HowMany.toFixed()+'Days');};

 

====

 

This topic has been closed for replies.
Correct answer JR Boulay

Hi

 

You should try this great free tool : http://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/

2 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
October 4, 2019
Acrobate du PDF, InDesigner et Photoshopographe
October 7, 2019
Thank you ! It's Great !!!
Inspiring
October 3, 2019

1. What results are you getting?

 

2. Have you checked the Acrobat JavaScript console for errors?

 

It is best to use the util.scand method to obtain the date object for a date in a string format.

October 3, 2019
Is something wrong? At present, the result is as expected. Just only can not changing the text color. In other words, "over" is displayed if today is past the day of Birthday. And "** D" is displayed if today is earlier than Birthday.