How can I compare a date input of format “MM/DD/YYYY” with the Date() function in Javascript?
For example:
if (InputDate < TodaysDate){
alert("You entered past date")
}
else if (InputDate > TodaysDate){
alert("You entered future date")
}
else if (InputDate = TodaysDate){
alert("You entered present date")
}
else{
alert("please enter a date")
}
Thanks all! Didnt find any of the above to work, but got it to work finally. Had to hack a little 😉
I did it by splitting the Date using getMonth, getDate and getYear and Parsing it and then comparing it. It works just as I want: