I have this code that I want to check if a date is in the past. I want to check it as soon as the date is entered, before form submission.
For those who use type="date" (introduced with HTML5) instead of type="text", it can be done this way:
function checkDate() { var date = this.value; if(date.valueAsDate <= new Date()) { //Date in the past } else { //Date in the future } }