Hi ,
We need help in Date Validation.
we have 2 Date fields on the form Start Date, End Date
The requirement is: End Date (May not be greater than 30 years from the start date).
I have written following script on End Date Exit event. But the problem is its calculating 30 years from the Current Date not from the Start Date
var
tDate = util.scand("mm/dd/yyyy", new Date());
var
M = tDate.getMonth();
var
D = tDate.getDate();
var
Y = tDate.getFullYear();
var
SRes = util.printd("yyyy-mm-dd", new Date((Y+30), M,D) );
//app.alert(SRes)
if
(SRes <= this.rawValue)
{
app.alert("May not be greater than 30 years from the start date")
xfa.host.setFocus(
this);
}
can someone please help me
Regards,
Jay
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You'll need to get javascript date from LCD field, and calculate & compare with the future date in javascript date.
try following script;
var sDate = StartDate.rawValue;
var wkStartDate = util.scand("yyyy-mm-dd", sDate);
var nYear = wkStartDate.getFullYear();
var nMonth = wkStartDate.getMonth();
var nDay = wkStartDate.getDate();
var wkFutureDate = new Date(nYear + 30 , nMonth, nDay);
sDate = EndDate.rawValue;
var wkEndDate = util.scand("yyyy-mm-dd", sDate);
if (wkEndDate.getTime() > wkFutureDate.getTime()){
xfa.host.messageBox("May not be greater than 30 years from the start date");
xfa.host.setFocus(this);
}
Views
Replies
Total Likes
Hi,
You'll need to get javascript date from LCD field, and calculate & compare with the future date in javascript date.
try following script;
var sDate = StartDate.rawValue;
var wkStartDate = util.scand("yyyy-mm-dd", sDate);
var nYear = wkStartDate.getFullYear();
var nMonth = wkStartDate.getMonth();
var nDay = wkStartDate.getDate();
var wkFutureDate = new Date(nYear + 30 , nMonth, nDay);
sDate = EndDate.rawValue;
var wkEndDate = util.scand("yyyy-mm-dd", sDate);
if (wkEndDate.getTime() > wkFutureDate.getTime()){
xfa.host.messageBox("May not be greater than 30 years from the start date");
xfa.host.setFocus(this);
}
Views
Replies
Total Likes
Thank you,
It's working perfect...
Regards,
Jay
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies