Javascript help with Date validation for pdf form.
Hi I have created a fillable pdf form.
"Text21" is a field in 'dd/mm/yyyy HH:MM' format.
I need a script for textbox "Text33" which is in dd/mm/yyyy format which should alert the user if the date entered in "Text33" is more than 30 months old from the date entered in "Text21". Also a seperate alert if the date entered is newer than "Text21".
Im not good at JS but have come up with the following from forums, though this just checks that field 21 needs to be filled first and then only if the date is newer than the "Text21" date.
Can anyone please guide or assist with the script? Thanks.
if (event.value) {
var startDateString = this.getField("Text21").valueAsString;
if (startDateString=="") {
app.alert("You must first enter Field 21");
event.rc = false;
} else {
var startDate = util.scand("dd/mm/yyyy", startDateString);
var endDate = util.scand("dd/mm/yyyy", event.value);
if (endDate.getTime() < startDate.getTime()) {
app.alert("Please recheck date - Must be within 30 months from Date of field 21");
event.rc = false;
}
}
}
