How to validate start dates and end dates
I have a form related to contracts. There are two fields for the contract terms: start date and end date.
My wish for the validation of these two fields:
1) That users are alerted to enter a start date before they enter an end date
2) That users are alerted to correct the end date if it comes before the start date
Here was my attempt:
event.rc = true;
if (event.value) {
var startDateString = this.getField("StartDate_af_date").value;
if (startDateString=="") {
app.alert("You must first fill-in the contract start date.");
event.rc = false;
} else {
var startDate = this.getField("StartDate_af_date").value;
var endDate = event.value;
if (endDate>startDate) {
app.alert("End date of the contract must be AFTER start date. Please correct.");
event.rc = false;
}
}
}
No matter what end date is entered, the alert pops up.
I'm a self-taught scripter and cobbled this together from another forum answer. I know I am missing something critical here but my research hasn't helped me.
Thank you!
