“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:
1 2 3 4 5 6 7 |
<form name="Form"> <input type="text" ng-pattern="/a-zA-Z/" /> <input type="text" ng-pattern="/0-9/" /> <input type="text" ng-pattern="/a-zA-Z0-9/" /> </form> |
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/
大三大四