Copy link to clipboard
Copied
I'm trying to auto fill a custom formatted field ("days") by combining two date fields ("day 1" and "day 2") with "and" in the middle. For example, if the user selects 6/2/2023 in the "day 1" field and 6/3/2023 in the "day 2" field, I want the "days" field to auto fill with "Friday, June 2nd, and Saturday, June 3rd".
I've added Custom Format Script and Custom Calculation Script to the "days" field and my dates are combined but not reformatted. I can't get the custom formatting to add the st, nd, rd or th to the day and drop the year.
MY CUSTOM FORMAT SCRIPT:
var date1 = this.getField("day1").value;
var date2 = this.getField("day2").value;
event.value = date1 + " and " + date2 + ".";
Copy link to clipboard
Copied
The date1 and date2 variables are already a string. As such, you don't need to use the "value" property on them to access their values. So either remove all the instances in the code where you do that, or simply change the first two lines to:
var date1 = this.getField("day1");
var date2 = this.getField("day2");
Copy link to clipboard
Copied
I resolved my issue with the "days" field not updating the date values if they are changed in the "day1" or "day2" fields by using the following:
FIELDS "day1" and "day2"
FORMAT - Date, Custom: "dddd, mmmm d"
VALIDATE - Run Custom Validation Script:
var date1 = this.getField("day1").value;
var date2 = this.getField("day2").value;
event.value = date1 + " and " + date2;
Copy link to clipboard
Copied
The date1 and date2 variables are already a string. As such, you don't need to use the "value" property on them to access their values. So either remove all the instances in the code where you do that, or simply change the first two lines to:
var date1 = this.getField("day1");
var date2 = this.getField("day2");
Copy link to clipboard
Copied
Thank you! That resolved my issue!
Copy link to clipboard
Copied
If I change the value of field(s) "day1" or "day2", the formatting in my "days" field does not work. The first day remains formatted as "day of week, month date(with st nd rd or th)" but he second day is "month day, year". It doesn't format correctly unless I go into the custom calculation of the "days" field and save it again. How do I make it recaculate if the "day1" or "day2" field value gets changed?
Copy link to clipboard
Copied
Sorry, I don't follow. What are you trying to achieve with this format script?
Copy link to clipboard
Copied
I'm creating holiday closing notices and on occassion, we're closed more than one day. I have three fields in my pdf; two date fields ("day1" and "day2") where the form user can select the dates and a third field (days) automatically combines the value of those two fields. For example, the notice reads "We will be closed Saturday, June 18th, and Monday, June 19th in observance of....".
Fields "day1" and "day2" are viewable only for the form user to select the date and they do not print. Field "days" is read only and does print.
Thank you for your help!
Copy link to clipboard
Copied
I resolved my issue with the "days" field not updating the date values if they are changed in the "day1" or "day2" fields by using the following:
FIELDS "day1" and "day2"
FORMAT - Date, Custom: "dddd, mmmm d"
VALIDATE - Run Custom Validation Script:
var date1 = this.getField("day1").value;
var date2 = this.getField("day2").value;
event.value = date1 + " and " + date2;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more