Tutorial 18 – how to use ng-pattern in Angularjs

How to use ng-pattern in Angularjs?

This sample will help you know about using ng-pattern in AngularJS.



 <html>  
   <head>  
     <title>Angular JS Model</title>  
     <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>  
     <script>  
       angular.module('MyForm', [])  
           .controller('myController', ['$scope', function($scope) {  
            }]);  
     </script>  
   </head>  
   <body ng-app="MyForm">  
 <h3>please input a number</h3>  
 <input ng-model="number" ng-pattern="/^\d+$/"/>   
 </body>  
  </html>  

You can use other ng-pattern for other format


No comments:

Post a Comment

Popular Posts