Ng-Pattern-6

 
In this we should only write alphabets between a-z,A-Z in textbox otherwise it give error.
 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <ng-form name="stringForm"> String Only: <input type="text" ng-model="number" name="number" ng-pattern="RE" /><br /> <span ng-show="stringForm.number.$error.pattern" style="color:red">Enter only string.</span> </ng-form> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.RE = /^[a-zA-Z ]{1,25}$/; }]); </script> </body> </html>
Output