Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

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

7 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

Former Community Member

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

Former Community Member

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

Former Community Member

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

Paul