I am working on some kind of personal info validation via javascript in my project. I have used regular expression to handle most validation. But I am surprised about DOB validation.
The regular expression pattern is working for some value and nor working for few other although values format are same.
My Regular expression for DOB which accepts only YYYY-MM-DD format:
/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/g
Value 1: 1912-12-12
Value 2: 2000-11-18
My javascript test function is return true for value 1 and returning false for value 2. I have also checked there is no space around values.
I have cross checked the same thing on below link:
Regular Expression Tester Javascript
Can anyone please let me know what is wrong with Value 2 or am I doing something wrong?
Thanks