I'm trying to prevent Javascript from automatically adjusting an invalid date.
For example:
2/31/2000
becomes 3/2/2000
var x = new Date("02/31/2000");
var maxDate = new Date("03/01/2020");
if(x > maxDate){
//date is invalid
} else {
//date is valid
}
//March 2st, 2020 is logged to the console
console.log(x);
What I need: is a solution (in Javascript or Jquery) that does not allow an invalid date like that, instead of auto adjust the month as seen above.
Solution exists here!
Stackoverflow just notified me that there's an answer to this already.
javascript date validation not validation February 31
Not sure what to do with this question... close it? Delete it? Can some mods take the appropriate action please? And thanks!