I'm trying to check if a date is valid. If I pass 31/02/2018 to new Date it will return Tue Mar 03 1987 00:00:00 GMT+0000 (GMT) as 31/02/2018 is not a real date. So how can I compare the passed date with the return date of new Date? or am I going about this the wrong way altogether.
function isDateValid() {
var dob = "31/02/1994",
isValidDate = false;
var reqs = dob.split("/"),
day = reqs[0],
month = reqs[1],
year = reqs[2];
var birthday = new Date(year + "-" + month + "-" + day);
if (birthday === "????") {
isValidDate = true;
}
return isValidDate;
}