I'm trying to verify that the user's data is valid.
I have the problem when I try to check dates like:
02/30/2018, or 1/32/2018, it creates them but the one of February puts it with days of March, and the one of January with February, increasing these days and increasing the months.
It occurred to me then to check if it keeps the month and day numbers after the conversation and it does not work either.
I've tried it with 07/11/2018
console.log("mon", mon);
date = new Date(year, mon - 1, day);
valid = !isNaN(date.valueOf());
console.log("date", date);
console.log("valid", valid);
if (date.getDay() === day) {
console.log("dia es el mismo");
} else {
console.log("dia cambio");
}
if (date.getDate() === mon) {
console.log("mes es el mismo");
} else {
console.log("mes cambio");
}
console.log("----");
console.log("date.getDay()" , date.getDay());
console.log("date.getDate()" , date.getDate());
if (!valid) {
format = false;
}