Currently, I am working on an Angular 13 project and I am trying to create a directive that will only allow users to type numbers and '/' in my date input field format of dd/mm/yyyy. Below is the regular expression (Regx) that I am using:
if (!String(myVal).match(new RegExp(/^\d+$/))) {
event.preventDefault();
}
Although this condition is functioning correctly, it restricts me from typing the '/' character needed for formatting dates. Does anyone have any suggestions on how I can modify my Regx to allow both numbers and the '/' character?
Thank you.