I have 2 date fields on a form. When I click the submit button I am trying to make sure the end date is after the start date.
Here is the code I am using:
var sDate = Date.parse(BackgroundInformation.Background.CheckingDateStart.rawValue); |
var eDate = Date.parse(BackgroundInformation.Background.CheckingDateEnd.rawValue);
xfa.host.messageBox("Start Date:" + BackgroundInformation.Background.CheckingDateStart.rawValue);
xfa.host.messageBox("eDate:"+eDate+" sDate:"+sDate);
if(sDate > eDate)
{ | |
valid = false; | |
fieldName +="Start Date is greater than End Date"; | |
} |
The message box shows the start date as 2014-10-30 but sDate is Nan.
I have tried:
var eDate = new Date(BackgroundInformation.Background.CheckingDateEnd.rawValue); |
var sDate = new Date(BackgroundInformation.Background.CheckingDateStart.rawValue);
and when I display sDate is says "Invalid Date"
Any ideas?
Solved! Go to Solution.
This should work..
var sDate = BackgroundInformation.Background.CheckingDateStart.value.date.value;
var eDate = BackgroundInformation.Background.CheckingDateEnd.value.date.value;
xfa.host.messageBox("eDate:"+eDate+" sDate:"+sDate);
if(sDate > eDate)
{ | |
valid = false; | |
fieldName +="Start Date is greater than End Date"; | |
} |
This should work..
var sDate = BackgroundInformation.Background.CheckingDateStart.value.date.value;
var eDate = BackgroundInformation.Background.CheckingDateEnd.value.date.value;
xfa.host.messageBox("eDate:"+eDate+" sDate:"+sDate);
if(sDate > eDate)
{ | |
valid = false; | |
fieldName +="Start Date is greater than End Date"; | |
} |
I'm assuming that you are using DateTime field in your form..
-Nith
Views
Replies
Total Likes
Hi there, I would suggest you to use FormCalc to do so, it is much more easier to work with date using this language...
By using FormCalc language you can use the following functions:
Date2Num() & Num2Date()
Hope this help!
Views
Replies
Total Likes
Thank you so much for the answer. It worked!
Views
Replies
Total Likes
Unfortunately I am using Javascript already. I don't think you can mix FormCalc and JS.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies