You are using the regular expression wrong. Try the following instead, noting the lack of
''
around the regex, and the use of .test
method on the pattern.
var errors = [],
pattern = /^(0[1-9]|1[0-2])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$/,
isValidBirthday,
cleanedBirthday;
cleanedBirthday = attrs.birthday && attrs.birthday.replace(/\s/g, '');
isValidBirthday = pattern.test(cleanedBirthday)