I have a requirement where a user should enter date in "MM/DD/YYYY" if available or else should be able to enter "NA" in the input field. Here is the stackblitz link where I am trying to achieve this functionality.
[Formatter not Validation Regex]
Note: User should be able to enter numbers or only N and A in NA sequence in the input field. Date validation is not required but the formatted numbers should be in this way ../../…. OR NA.
You need add an OR expression to your regex for contemplate the case of NA.
Now, the regex will looks like this:
In your regex, the two alternative are anchored separately:
^([0-2][0-9]|(3)[0-1])(\/)(((0)[0-9])|((1)[0-2]))(\/)\d{4}
MM/DD/YYYY|
OrNA$
NASee the regex demo.
It will acept: