Need working date pattern for html <input>
by mfoley from LinuxQuestions.org on (#4S3SP)
I've tested various patterns, including going to http://html5pattern.com/Dates. No patterns work perfectly. The closest I've found is
Code:<input type="text" placeholder="mm/dd/yyyy"
pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d"/>but this one requires a 2 digit month, e.g. "01", instead of simply "1", and it requires a 4 digit year. For the latter, I'd like it to accept either 4 digits, or the last two digits only.
Does anyone know how I can modify the pattern to give me what I want?
Perhaps more importantly, is there a tutorial out there somewhere on these pattern regex's? I haven't been able to find anything.


Code:<input type="text" placeholder="mm/dd/yyyy"
pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d"/>but this one requires a 2 digit month, e.g. "01", instead of simply "1", and it requires a 4 digit year. For the latter, I'd like it to accept either 4 digits, or the last two digits only.
Does anyone know how I can modify the pattern to give me what I want?
Perhaps more importantly, is there a tutorial out there somewhere on these pattern regex's? I haven't been able to find anything.