Trying to test out some JS form validation. Not sending this information to any database or anything; just trying to hammer down the format for now. All my regex checks are working fine except for birth
It seems as though there is something wrong in the regex check because when I put another check in there with a different format, it works fine. I want them to enter the birthday in mm/dd/yyyy fashion and display the proper error if not. Any help is appreciated!
if(birth == "") {
printError("birthErr", "Please enter your birthday");
} else {
var regex = '/^((0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2})*$/';
if(regex.test(birth) === false) {
printError("birthErr", "Please enter a valid birthday");
} else {
printError("birthErr", "");
birthErr = false;
}
}