Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Two dates, 1 text field calculates number of days between the Two dates.

Avatar

Level 3

Hello Forum,

Does anyone have a script that could calculate the number of days between two dates?

I needed the number of days to auto generate after 2 dates are selected:

example for my form:

Start Date 11/1/09

End Date 11/11/09

(TextField) shows "10"

Thank You,

Arnold

0 Replies

Avatar

Level 3

Hi Paul,

Is there some script that I can add to the

TextField1 Box? Without the use of a button?

Arnold

Avatar

Level 10

Sure .....script is associated with an event that happens (the user enters, the field, the user changes data, the user exits the field .....). The question becomes when do you want to trigger the code. Typically it is on the exit event of the field (that signifies that the user is done with the field). In this case you woudl have to validate that the other date field was filled out before you even try to do the comparison.

Paul

Avatar

Level 3

So for instance if both date fields are filled the text field will calculate the days.

What script should I use for the TextField1 and where will it be set(change,exit,click,mouseup,mousedown)

I'm not sure how to finish it.

Arnols

Avatar

Level 10

I woudl put it on th eexit event of the second date field.

Paul

Avatar

Level 3

Could you provide the script for line?

It would help

Thank You,

Arnold

Avatar

Level 10

Just copy and paste the code form the button click event to the exit event of field 2.

Paul