I am building a realtime input validation for a date format. That is supposed to validate the date format while typing. In order to do that i need a regex to do the following: X is a number {0,9} and every step of the input needs to be valid.
I tried building a regex and finding one fitting but both without success. Best regards.
Valid Input Cases
"" - i.e empty
"X" - i.e. 3
"XX" - i.e. 31
"XX." - i.e. 31.
"XX.X" - i.e. 31.1
"XX.XX" - i.e. 31.10
"XX.XX." - i.e. 31.10.
"XX.XX.X" - i.e. 31.10.1
"XX.XX.XX" - i.e. 31.10.19
"XX.XX.XXX" - i.e. 31.10.199
"XX.XX.XXXX" - i.e. 31.10.1998
Edit: To clarify this will not replace date validation this will only be used in an HTML Input element in react to prevent the user from typing other chars.