Angular ng-pattern Validation Examples

Pattern Matching – This type of validation is based on regular expression pattern expression and also called regular expression validation. This validation checks that the value of an input field matches a specific regular expression pattern. For this we use the “ng-pattern” directive of AngularJS.”

Syntax: ng-pattern=”/PATTERN/”


In the preceding example:

1st input field will only use a-z and A-Z characters,
2nd input field will only use 0-9 characters,
3rd input field will only use a-z,A-Z and 0-9 characters.

Telephone – custom directive


Sam is a passionate web developer from England. In his spare time he enjoys coding, playing chess, reading and investing.

One thought on “Angular ng-pattern Validation Examples

Leave a Reply

Your email address will not be published. Required fields are marked *