Copy link to clipboard
Copied
Hello,
I am creating a fillable PDF form using Adobe Acrobat DC. There are two fields that requires the person to select dates - Start and End date. How can we have the End date check to make sure that it is AFTER the Start date? Please see attachment for screen capture.
You will have to write a custom validation script for the end date field. Something like this shoud work (not tested, so there might be errors):
var retVal = true;
// get information from "Date1"
var d1 = this.getField("Date1_af_date").value;
if (d1 == "") {
app.alert("Start date is empty");
retVal = false;
}
if (retVal && event.value == "") {
app.alert("End date is empty");
retVal = false;
}
if (retVal) {
var d1 = new Date(d1);
var d2 = new Date(event.value);
if (d
...
Copy link to clipboard
Copied
You will have to write a custom validation script for the end date field. Something like this shoud work (not tested, so there might be errors):
var retVal = true;
// get information from "Date1"
var d1 = this.getField("Date1_af_date").value;
if (d1 == "") {
app.alert("Start date is empty");
retVal = false;
}
if (retVal && event.value == "") {
app.alert("End date is empty");
retVal = false;
}
if (retVal) {
var d1 = new Date(d1);
var d2 = new Date(event.value);
if (d1 > d2) {
app.alert("End date needs to be after start date");
retVal = false;
}
}
event.rc = retVal;
Copy link to clipboard
Copied
Thanks Karl! It works!
Copy link to clipboard
Copied
Hi Karl, [total newbie] almost the same request, but need a custom validation script for a fillable form that allows the user to only select a future date 30 days from today's date. Thanks in advance—Rudy
Copy link to clipboard
Copied
Rudy, please post a new question.