2

I am trying to test validation on this control but when I take the digits down to 9 and back to 10 the validation is still invalid.

<input type="tel" #phone="ngModel" required pattern="^\d{10}$" class="form-control" [class.is-invalid]="phone.invalid && phone.touched" name="phone" [(ngModel)]="userModel.phone">

1 Answer 1

2

You have to use pattern attribute like this ::

<input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>

More information about pattern validator ::

https://angular.io/api/forms/PatternValidator

https://www.concretepage.com/angular-2/angular-2-4-pattern-validation-example

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.