I am creating a date formatter.
On input (input event),it will format the input into the correct format as the user types, for example, 11/22/2020.
There are certain conditions to be met.
- The first character (month first character must either be a 0 or 1)
- If the first character in the month is a 1, then the second month character must be either 0,1, or 2
- The delimiters ("/") are automatically inserted as the user types
- The first character of the day must either be 0,1,2, or 3
- All characters except the delimiters must be number characters
The issue comes into play when the user removes a character.
How do I keep track of the positions of the characters upon input? Also, how do I keep track of the positions of the characters that are deleted or replaced?