Reputation: 181
Hi all having a little problem with regex and Jquery in checking that a date will work correctly.
Currently it doesn't accept the number 01 but does 02+ but works as expected with ranges above 31.
this is the js fiddle page. http://jsfiddle.net/b3aHt/
Thanks
Upvotes: 2
Views: 327
Reputation: 129782
01
fails because of dob < 2
.
I don't think regular expressions make for a very neat solution here. I would rather test
if(dob.length != 2 || isNaN(dob) || dob < 0 || dob > 31) {
// not between 01 and 31
}
Upvotes: 3