Hello
I am creating a travel form on adobe designer 7.0 for employees to fill out before they go on vacation. So i wrote a script that makes sure the the date entered for DateFrom is >= the current date and the DateTo is >= DateFrom. I have been told to make the date format MM/DD/YY but for some reason the script only works when the format is MM/DD/YYYY.
Here is my script For DateFrom:
if (Date() < Date2Num($.formattedValue, "MM/DD/YYYY"))
then
xfa.host.setFocus("xfa.form.form1.DateTo")
else
xfa.host.setFocus("xfa.form.form1.DateFrom")
xfa.host.messageBox("Your requested date can NOT come before the current date","Warning.",1)
endif
and the script for DateTo:
if (Date2Num($.formattedValue, "MM/DD/YYYY") >= Date2Num(xfa.form.form1.DateFrom.formattedValue, "MM/DD/YYYY"))
then
xfa.host.setFocus("xfa.form.form1.enterC")
else
xfa.host.messageBox("The 'TO' Date must come after the 'FROM' Date", "TO DATE ERROR")
xfa.host.setFocus("xfa.form.form1.DateTo")
endif
enterC is the next focus object after DateTo
I have tried the obvious by switching the formattedValue to "MM/DD/YY" but with no success. I have also tried switching the Display Pattern, Validation Pattern, and the Data Pattern to "MM/DD/YY" but nothing seems to work. Does anyone know how to make this work with MM/DD/YY?
Thanks in advance for any help
Nick
Solved! Go to Solution.
Views
Replies
Total Likes
Idea is to keep the display format separate from the scripting format. You can use any format that you like in Display format and will not interfere with the script. In the script I would always like to use "YYYY-MM-DD" the international format which you do not have to worry about as long as you set the Display and Edit formats as you like.
Views
Replies
Total Likes
Irrespective of the display pattern/format I would use the following FormCalc code in your situation. Also check the attachment.
'exit' event of the DateFrom:
if (Date() <= Date2Num($.rawValue, "YYYY-MM-DD")) then
//xfa.host.setFocus("xfa.form.form1.DateTo")
var v1
v1=1
else
xfa.host.setFocus("xfa.form.form1.DateFrom")
xfa.host.messageBox("Your requested date can NOT come before the current date","Warning.",1)
endif
'exit' event of the DateTo
if (Date2Num($.rawValue, "YYYY-MM-DD") > Date2Num(xfa.form.form1.DateFrom.rawValue, "YYYY-MM-DD")) then
//xfa.host.setFocus("xfa.form.form1.enterC")
var v1
v1 =1
else
xfa.host.messageBox("The 'TO' Date must come after the 'FROM' Date", "TO DATE ERROR")
xfa.host.setFocus("xfa.form.form1.DateTo")
endif
Thank you very much for the help. It works great but the fromat is slightly different. I'm guessing that only certain formats can be used in date fields, so that 'MM/DD/YY' is just not compatible with Designer? If that is the case then your script would be the answer I was looking for. If that is not the case, could i just substitute 'MM/DD/YY' in for the 'YYYY-MM-DD'? or would that not work?
thanks again for the help
Nick
Views
Replies
Total Likes
Idea is to keep the display format separate from the scripting format. You can use any format that you like in Display format and will not interfere with the script. In the script I would always like to use "YYYY-MM-DD" the international format which you do not have to worry about as long as you set the Display and Edit formats as you like.
Views
Replies
Total Likes
Oh ok I did not know that is how it worked. Thank you very much!!!!!
Views
Replies
Total Likes