Wednesday, November 25, 2015

Angular Patterns

ng-Pattern : We can use angular patterns to validate input type. adds the pattern validator to ngModel. It is most often used for text-based input controls, but can also be applied to custom text-based controls

Edit in plunkr

Steps involved
  • Specify input type
  • Specify the angular pattern in regular expression

<input type="number" name="price_field1" ng-model="price1" ng-pattern="/^(0|[1-9][0-9]*)$/" />
         <span ng-show="frm1.price_field1.$error.pattern">
            Not a valid number !


No comments:

Post a Comment