Copy link to clipboard
Copied
II a person enters a date, that is less than 3 years from today. The message would open and when they close the message the form would also. The field is currently a date field m/dd/yy format. No other validation or calculations currently set on the field. The field they would be entering the date in is called APPOINTMENTDATE.
Any help would be greatly appreciated.
Thank you in advance.
You can use this code as the field's custom validation script:
if (event.value) {
var d1 = util.scand("m/dd/yy", event.value);
var d2 = new Date();
d2.setFullYear(d2.getFullYear()+3);
if (d1.getTime()<d2.getTime()) {
app.alert("Error! The entered date is less than three years from today.");
event.rc = false;
}
}
Copy link to clipboard
Copied
You can use this code as the field's custom validation script:
if (event.value) {
var d1 = util.scand("m/dd/yy", event.value);
var d2 = new Date();
d2.setFullYear(d2.getFullYear()+3);
if (d1.getTime()<d2.getTime()) {
app.alert("Error! The entered date is less than three years from today.");
event.rc = false;
}
}
Copy link to clipboard
Copied
If I wanted to use a specific date say 4/01/16 would it be this
if (event.value) {
var d1 = util.scand("m/dd/yy", event.value);
var d2 = util.scand("m/dd/yy", 4/01/19);
if (d1)<d2.) {
app.alert("Error! At this time you are not Eligible to file this application. Your appointment date must be before April 1, 2016.");
event.rc = false;
}
}
Copy link to clipboard
Copied
If I wanted to use a specific date say 4/01/16 would it be this
if (event.value) {
var d1 = util.scand("m/dd/yy", event.value);
var d2 = util.scand("m/dd/yy", 4/01/19);
if (d1)<d2.) {
app.alert("Error! At this time you are not Eligible to file this application. Your appointment date must be before April 1, 2016.");
event.rc = false;
}
}
Copy link to clipboard
Copied
Almost. Change this line:
var d2 = util.scand("m/dd/yy", 4/01/19);
To:
var d2 = util.scand("m/dd/yy", "4/01/19");
Copy link to clipboard
Copied
Also, change the line after that back to what it was...
Copy link to clipboard
Copied
Thank you. With your help I adjusted the code and here is my final product that is giving me my results.
if (event.value) {
var d1 = util.scand("m/dd/yy", event.value);
var d2 = util.scand("m/dd/yy", "4/1/2016");
if (d1>d2) {
app.alert("Error! At this time you are not Eligible to file this application. Your appointment date must be before April 1, 2016.");
event.rc = false;
}
}