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

EASY SOLUTION FOR SOMEONE, JUST NOT ME

Community Beginner ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

I HAVE 2 FIELDS. A "TEST DATE" FIELD, WHICH I HAVE SETUP TO AUTOMATICALLY FILL IN TODAY'S DATE. FORMATED WITH DATE.

 

I HAVE ANOTHER FIELD "REG DATE" WHICH IS FORMATED THE SAME AS DATE. HOWEVER, THIS FIELD IS MANUALLY SELECTED BY THE USER.

 

WHAT I'D LIKE TO DO IS MAKE THIS "REG DATE" FIELD DISPLAY GREEN AND RED BASED ON THE DATE ENTERED. GREEN IF IT IS NOT PAST THE "TEST DATE" FIELD, BUT RED IF IT IS PAST "TEST DATE" FIELD. 

 

ANY IDEA'S HOW TO ACCOMPLISH THIS?

TOPICS
JavaScript , PDF forms

Views

747

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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

Having fixed these issues, it worked fine. See attached.

View solution in original post

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 ,
Jul 12, 2024 Jul 12, 2024

Copy link to clipboard

Copied

Change the code to this:

 

if (event.value) {
	var testDate = util.scand("mm/dd/yyyy", this.getField("TESTDATE").valueAsString);
	testDate.setHours(0);
	testDate.setMinutes(0);
	testDate.setSeconds(0);
	testDate.setMilliseconds(0);
	var regDate = util.scand("m/d/yy", event.value);
	regDate.setHours(0);
	regDate.setMinutes(0);
	regDate.setSeconds(0);
	regDate.setMilliseconds(0);
	event.target.fillColor = (regDate.getTime()<testDate.getTime()) ? color.red : color.transparent;
} else event.target.fillColor = color.transparent;

View solution in original post

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
Adobe Employee ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

Hi there

Hope you are doing well and thanks for reaching out.

The workflow you are trying to achieve is might be possible using JavaScript. For more information, please check the help pages listed below:
https://acrobatusers.com/tutorials/javascript_console/
https://helpx.adobe.com/acrobat/using/applying-actions-scripts-pdfs.html

Hope it will help

Regards
Amal

Regards
Amal

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 ,
Jun 28, 2024 Jun 28, 2024

Copy link to clipboard

Copied

- What is the date pattern used in these fields?

- What should be the color if the two dates are the same?

- What should happen if "TEST DATE" is empty and "REG DATE" is not?

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 Beginner ,
Jun 28, 2024 Jun 28, 2024

Copy link to clipboard

Copied

THE DATE PATTERNS ARE:

- What is the date pattern used in these fields? "TEST DATE:"  FIELD IS: MM/DD/YYYY | "REG EXPIRE DATE:" FIELD IS: MM/DD/YY

- What should be the color if the two dates are the same? "TEST DATE:" FIELD SHOULDN'T CHANGE ANY COLORS

I WANT TO GET THE "REG EXPIRE DATE:" FIELD TO CHECK AGAINST THE TEST DATE FIELD. IF IT IS AN EARILER DATE THAN THE CURRENT DATE, I WANT IT TO FLAG THE FIELD RED. I DON'T NEED IT TO DO ANY GREEN AFTER I WAS THINKING ABOUT IT BUT, IF I DID, I'D LIKE IT TO BE GREEN IF IT'S GOOD, RED IF IT'S EXPIRED BASICALLY.

- What should happen if "TEST DATE" is empty and "REG DATE" is not? NEITHER OF THESE FIELDS CAN BE EMPTY. THEY ARE REQUIRED TO BE FILLED IN OR THE DOCUMENT WON'T ALLOW PRINTING. I HAVE THAT FIELD SCRIPTED TO AUTO ENTER THE CURRENT DATE WHEN THE PDF IS OPENED. 

 

 

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 Beginner ,
Jul 10, 2024 Jul 10, 2024

Copy link to clipboard

Copied

IS THERE ANY HELP OUT THERE THAT SOMEONE CAN GIVE ON THIS SIMPLE SOLUTION THAT I'M NOT ABLE TO GET TO WORK?

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

I didn't get a notification about your reply from earlier due to a bug in the forums system...

You can use this code as the custom calculation script of the "REG DATE" field:

 

if (event.value) {
	var testDate = util.scand("mm/dd/yyyy", this.getField("TEST DATE").valueAsString);
	var regDate = util.scand("mm/dd/yyyy", event.value);
	event.target.fillColor = (regDate.getTime()<testDate.getTime()) ? color.red : color.green;
} else event.target.fillColor = color.transparent;

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

PS. Please stop writing in all-caps. It makes it very annoying to read your replies...

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 Beginner ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

My aplogies, it's because i'm old and have a hard time seeing small charactures. i'll do my best not do to that. everything i do is always in caps just for that reason. i appreciate your help very much. i'll give this a try and let you know.

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 Beginner ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

I tried this and it did not function. Does it make a difference if the fields are assigned a format category of Date with the dropdown calendar? i tried this in both custom validation script and custom caluclation script but netiher worked. 

 

i have another field there that does kind of simular which is the TOTALGVWR field. the code for this is located in the validate custom validation script: 

event.target.textColor = color.black;
if (+event.value > 26000) event.target.fillColor = color.green;
else if (+event.value < 26001) event.target.fillColor = color.red;

with 

TRLGVWR+PWRGVWR in the calculate tab simplified field notation. this works flawlessly but i can't figure out how to do this for 2 date boxes. 

 

The "SKILLS TEST DATE" field is set to automatcially fill in today's date with this code in the actions tab, mouse up, (run a javascript):

this.addScript("init", "this.getField(\"SKILLS TEST DATE\").value = new Date();");

 

i see the concept in your code and that's exactly what i'm looking for, minus the green portion. i'm looking for this to do the color change based on a mouse up or after a date is selected in the calendar picker.

If date of "REG DATE" is equal to OR after "SKILLS TEST DATE" then leave transparent.

if date of "REG DATE" is prior to "SKILLS TEST DATE" then change the color of the field to red. 

I'm not sure if this helps you any or not but i uploaded the file so you can see how this form works if that would be easier.

 

 

 

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

- There's no field in the file called "SKILLS TEST DATE".

- Where did you place the code I provided? I don't see it under "REG DATE".

 

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

- There's also no "TEST DATE". There is a "TESTDATE", though, so you will have to adjust the code accordingly.

- Also, the format of "REG DATE" is not as you specified. It's actually "m/d/yy".

- You should not assign an addScript command to the mouse up event of a field. It's not needed, and will fail in Reader.

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

Having fixed these issues, it worked fine. See attached.

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 Beginner ,
Jul 12, 2024 Jul 12, 2024

Copy link to clipboard

Copied

THANK YOU SO MUCH THIS DOES WORK. I BELEIVE IT PROBABLY WORKED THE LAST TIME TOO BUT I HAD MY FORM SET TO HIGHLIGHT ALL REQUIRED FIELDS AND THAT'S WHY IT WASN'T SHOWING UP AFTER YOU SELECTED THE DATES.

 

THE ONLY ISSUE I SEEN ON IT WAS THE ISSUE OF IF BOTH FIELDS HAVE THE SAME DATE IN THEM, THEN REG DATE IS RED. THAT SHOULD BE GREEN OR TRANSPARENT SO TO SPEAK. I'D LIKE TO GO AHEAD AND REMOVE THE GREEN AND JUST USE TRANSPARENT FOR GOOD TO GO AND RED FOR EXPIRED REGISTRATIONS. I TRIED TO TOY WITH THAT A LITTLE AND GOT A FEW ERRORS ON SYNTAX AND SUCH. 

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 ,
Jul 12, 2024 Jul 12, 2024

Copy link to clipboard

Copied

Change the code to this:

 

if (event.value) {
	var testDate = util.scand("mm/dd/yyyy", this.getField("TESTDATE").valueAsString);
	testDate.setHours(0);
	testDate.setMinutes(0);
	testDate.setSeconds(0);
	testDate.setMilliseconds(0);
	var regDate = util.scand("m/d/yy", event.value);
	regDate.setHours(0);
	regDate.setMinutes(0);
	regDate.setSeconds(0);
	regDate.setMilliseconds(0);
	event.target.fillColor = (regDate.getTime()<testDate.getTime()) ? color.red : color.transparent;
} else event.target.fillColor = color.transparent;

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 Beginner ,
Jul 12, 2024 Jul 12, 2024

Copy link to clipboard

Copied

LATEST

THAT WORKS GREAT NOW! THANK YOU SO MUCH. NOW THIS PROJECT IS COMPLETED AND I CAN GET BACK TO MY NORMAL JOB. 

 

I GREATLY APPRECIATE THE HELP!!

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