I want to validate a person's date of birth and I am stuck trying to figure out how to go about checking if the YEAR of birth is valid using the ISO date format like this yyyy-mm-dd. I want to check if the year is valid and then use the last 2 digits of the year. So I want the format to be yy-mm-dd after validating the year. I have checked the month and the day but I am struggling to figure out how to validate the year before and after 2000. This is my code for checking MONTH and DAY function checkDateOfBirth(dateString){ const year = dateString.substring(0, 2); const month = dateString.substring(2, 4); const day = dateString.substring(4, 6); if ( day > 31 || month > 12 || (month == 2 && day > 29) || (month == (4 || 6 || 9 || 11) && day > 30) ) { return false; } return true; } The input string would be "940912" in the format yy-mm-dd. Any help/suggestions would be great Via Ac
A site where you can share knowledge