how to validate field date range, despite allowable formats of m/d/yyyy and just yyyy.
Hello,
I have a form where I have to allow date formats of m/d/yyyy and just yyyy. My field format is working great for that. I found this method online for that:
if (!event.value) {
event.value = "mm/dd/yy"; // Default format
} else {
try {
var date = util.scand("mm/dd/yy", event.value);
event.value = util.printd("mm/dd/yy", date);
} catch (e1) {
try {
var date2 = util.scand("yyyy", event.value);
event.value = util.printd("yyyy", date2);
} catch (e2) {
app.alert("Invalid date format. Use mm/dd/yy or yyyy.");
event.value = "";
}
}
}
I'm having problems adding validation so that the date cannot be greater than today or older than 1/1/2000, whether it was entered as m/d/yyyy or yyyy. Today is 5/14/25, so anything greater than that, older than 1/1/2000 or a year that doesn't fall between 2000 and 2025 should result in a message to user that date is not valid.
Thanks to anyone who can steer me in the right direction. 🙂
I've been searching out a solution for a few hours. Does anyone have a suggestion?
