angular input date pattern validation 1

angular input date pattern validation

(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))

Here is what the above code is Doing:
1. The first part of the code, (?:19|20)[0-9]{2} is matching the year.
2. The next part, (?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31)) is matching the month and the day.
3. The first part of the second part, (?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]) is matching the month and the day for months that have 30 or 31 days.
4. The second part of the second part, (?:(?!02)(?:0[1-9]|1[0-2])-(?:30)) is matching the month and the day for months that have 30 days.
5. The third part of the second part, (?:(?:0[13578]|1[02])-31) is matching the month and the day for months that have 31 days.

Similar Posts