Expand my Community achievements bar.

FormCalc issues with Windows 7

Avatar

Level 1

Hi,

I am using FormCalc to check two date fields. The first one, the arrival date, should not be earlier than today's date. The second field, departure date, should not be earlier than the arrival date.  The FormCalc is in the Exit event of the date field.  It works perfectly fine in XP, but the validation is not working Windows 7.   The user does not get the pop up box at all and is able to submit the form with invalid dates.  Does anyone know of an issue with FormCalc and Win 7??   It does not seems to be an issue with the Adobe Reader version.  I tried with version 9.3.4 and XP and someone else with Adobe Reader 9.3.4 and Win 7 and the date validation did not work.

Here is my code:

Arrival Date:

form1.page1.main.travelInfo.arrDate::exit - (FormCalc, client)

if (Date2Num($.formattedValue, "MMMM D, YYYY") < Date()) then

    xfa.host.messageBox("Arrival Date must be later than the current date")

    $ = ""

endif

Daparture Date:

form1.page1.main.travelInfo.deptDate::exit - (FormCalc, client)

if (form1.page1.main.travelInfo.deptDate.rawValue <  form1.page1.main.travelInfo.arrDate.rawValue) then

    xfa.host.messageBox("Departure Date must be later than the Arrival Date")

    $ = ""

endif

Thanks in advance!

6 Replies

Avatar

Level 8

Seems to work with Reader 10.0.1, is an update to Reader an option?

Avatar

Level 10

Hi,

I don't see a reason why FormCalc should behave diffently on Win 7.

This language is part of Acrobat/Reader not of the OS.

You should change the script in the deptDate field, because you currently try to compare two strings not integers.

Avatar

Level 1

radzmar - Thanks so much for your suggestion.  I changed the code in the deptDate field to the above code, but the pop up box comes up no matter what date I choose, so it's not validating correctly.   The arrDate field works fine.  Any thoughts?

Code from deptDate:

 

form1.page1.main.travelInfo.deptDate::exit - (FormCalc, client)

 

 

if

(Date2Num($.formattedValue, "MMMM D, YYYY") lt Date2Num(arrDate.formattedValue, "MMMM D, YYYY"))  then

$host.messageBox("Departure Date must be later than the Arrival Date")

$

=

""

endif

Avatar

Level 10

Hi,

do a test, to determine, that the patterns you use are correct.

In the exit event just add:

If it is correct the message box should display 41065 for todays date.

But if it displays 0 for one of the date fields, then this field uses another display pattern then "MMMM D, YYYY".

The Date2Num method only returns the correct result if the patterns are written in the same way.

Avatar

Level 1

Hi,

It turns out there was an issue with Adobe Reader version 9.3.1.  Once I upgraded to version 10.1.3 and I fixed the pattern in the departure date field, it worked.  However, after further testing, I foung that if you enter the Departure Date FIRST and then the Arrival Date, it allows you to enter an invalid date (ie: earlier than the current date or a date ealier than the arrival date)   How do I add validation for this scenario, in which the user enters the fields out of order?  (departure date and then arrival date)    Right now, it only works with the above FormCalc if the user enters the Arrival Date and then the Departure Date.

Thanks!!

Avatar

Level 7

It is not working out of order because you have the code in the exit event - so it only fires when you leave the field. If you put the code from the departure date in the layoutReady event instead then it will work how you want it.