Hello,
On my form, I need for the user to enter a "date needed by". Then I need to compare the needed by date to today's date and if it is less than 15 days away, I need to display a message: We need more than 15 days to fulfill your order."
I've found some scripts on the Forum, but none are exactly what I need and I'm having trouble figuring out how to edit them for this specific problem. Any help is appreciated.
Thanks,
MDawn
Solved! Go to Solution.
Ok, you just need to add a script to the exit event of the dateNeeded field.
if (date2num($.formattedValue, "MM/DD/YYYY") lt date() + 15) then
$host.messageBox("date hast be at least 15 days in the future", "wrong date entered", 0, 0)
endif
var cDate = Date()
var eDate = EnteredDate //your field name for entered date field
var diff = cDate - eDate
If diff < 15;
app.alert("The number of days between the two dates is: "+ diff/1000/60/60/24);
give that a try, I dont know if syntax is right, I am just a begginer at Javascript as well. Put this in exit event of the entered date field. with Javascript language.
Views
Replies
Total Likes
If you work with dates you should use FormCalc, as it already brings functions for date calculation.
Try this script in the exit event of your date field.
var entryDate = date2num($.formattedValue, "MM/DD/YYYY")
var futureDate = date() + 15
if (entryDate lt date()) then
$host.messageBox("Date cannot be in the past", "Date in the past", 0, 0)
else if (entryDate gt futureDate) then
$host.messageBox("Date is too far in the future", "Date in the future", 0, 0)
endif
Views
Replies
Total Likes
Hi, Thanks for your help. I'm not as familiar with FormCalc and could use some help translating what's happening on my form.
I have the formDate which is a field that displays the current day's date. then I have the dateNeeded where the user will enter a date.
I need to compare the dateNeeded to formDate and dateNeeded must be more than 15 days from the formDate. Does that make sense. Then if the dateNeeded is not more than 15 days from the formDate, I need a message to display.
Thanks again for your help,
MDawn
Views
Replies
Total Likes
Ok, you just need to add a script to the exit event of the dateNeeded field.
if (date2num($.formattedValue, "MM/DD/YYYY") lt date() + 15) then
$host.messageBox("date hast be at least 15 days in the future", "wrong date entered", 0, 0)
endif
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies