0
Date Validation
I know sometimes regex expressions seems creepy.I was trying to write a date validation regex and came up with this /^\d{4}[/-](0\d|1[0-2])[/-]([0-2]\d|3[0-1])$/g but its somehow incorrect since a month like february can not have 30 and 31 days or 29days(unless its a leap year).Is there an improvement of this or sometimes one should allow false positives or false negatives?And by the way which is better false negatives or positives?
2 odpowiedzi
+ 1
I personally would write the regex as a primary validation of data type and placement. If the date fits the pattern then use javaScript to do the actual data validation.
0
Sounds like a cool idea...Thanks Grahambo