In my .ts
component file, I have a variable that aims to prevent invalid phone numbers from being entered:
public phonePattern = ^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$;
In the HTML component file, there is a text box defined as follows:
<input type="text" [(ngModel)]="contact.phone" [pattern]="phonePattern" placeholder="Enter Phone Number" />
The binding for [pattern]
does not appear to be functioning correctly. Any suggestions on how to fix this?