Reputation: 188
How do I create a date field in angular/html to force the user to input the date in a specific format like MM/yyyy without any validation?
For example: when the user enters the first two digits of month, he should see a slash '/' so that he can enter only 4 more digits for year.
I know it can be done with a simple regex validation, but that will allow the user to enter the date in any format and then validate to show the error.
Upvotes: 0
Views: 944
Reputation: 19248
Instead of fiddling with Javascript and HTML code I would suggest you take a look at some of the baked-in date parser
directives offered by angular-bootstrap as a starting point and tweak things from there.
Example 1: Date parser
Example 2: Date picker
Example 3: Date picker with popup
As requested by OP. He is looking at inputting Month/Year only. This example might be more relevant;
Upvotes: 1