Copy link to clipboard
Copied
I have a Suspense Date Block on my Form and I want an Error to pop up not allowing users to enter a date that is within 10 days of the current date and time. I need a JAVA Script to make this happen, I am not versed in Java Script to make this happen and am looking for help from the community. BLUF: If todays Date is 05/24/2021 9:41am and you try to put in a Suspense daye earilier than 06/03/2021 9:41am than the system will give you an error saying "As per SOP your Request must be Approved by the CoS".
Thank you for your help.
Copy link to clipboard
Copied
You can do it using this code as the field's custom validation script:
if (event.value) {
var d = util.scand("m/d/yy HH:MM", event.value);
var now = new Date();
var tenDays = 864000000;
if ((d.getTime()-now.getTime())<tenDays) {
app.alert("As per SOP your Request must be Approved by the CoS");
event.rc = false;
}
}
Copy link to clipboard
Copied
That worked Perfectly, For my reference what is the 864000000 refence for? is that JS Math for 10 days?
Copy link to clipboard
Copied
It's the number of milliseconds in 10 days.