I've got a field on a jsp which takes a text date in mm/dd/yyyy format. I need to make sure that the date entered into that field is not greater than the current system date. Here is what I've come up with so far:
function isFutureDate(inputDate) {
var now = new Date();
now = now.getTime();
var day = inputDate.value.substring(3,5);
var month = inputDate.value.substring(0,2);
var year = inputDate.value.substring(6);
//take the parse date values and create a Date object
var dateToCheck = new Date();
dateToCheck.setYear(year);
dateToCheck.setMonth(month);
dateToCheck.setDate(day);
alert("dateToCheck = " + dateToCheck);
var checkDate = dateToCheck.getTime();
alert("checkDate = " + checkDate);
alert("day = " + day + " month = " + month + " year = " + year);
if (checkDate > now)
{
alert("The date entered may not be in the future");
return false;
}
return true;
}
My alert("checkDate = " + checkDate); shows checkdate as undefined.
Can someone point out what I'm doing incorrectly?
Thanks,
Chris