Angular ng-pattern Validation Examples

Handsontable JavaScript Spreadsheet Most popular component for web apps

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/”

Example:

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
https://jsfiddle.net/2G8gA/1/

Refs:
https://www.c-sharpcorner.com/UploadFile/75a48f/various-types-of-form-validation-in-angularjs/

Sam Deering

Sam Deering

Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and sharing what he learns with others.

One thought on “Angular ng-pattern Validation Examples

Leave a Reply

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