Home > Article > Web Front-end > The use of regular expressions in angularJS
This article introduces the use of regular expressions in angularJS. It has a certain reference value. Now I share it with you. Friends in need can refer to it
<!DOCTYPE > <html> <head> <meta charset="utf-8" /> <title>angular</title> <script src="angular-1.5.8/angular.min.js"></script> </head> <body> <form ng-app="myApp" ng-controller="validateCtrl" name="myForm" novalidate> <p>用户名:<br> <input type="text" name="user" ng-model="user" required ng-pattern="/[a-zA-Z]/"> <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid"> <span ng-show="myForm.user.$invalid">用户名是必须的。</span> </span> </p> </form> <script> var app = angular.module('myApp', []); app.controller('validateCtrl', function($scope) { $scope.user = 'John Doe'; $scope.email = 'john.doe@gmail.com'; }); </script> </body> </html>
Related recommendations:
How to use regular expressions in JavaScript
Introduction to the use of regular expressions in C
Usage of regular expressions in JAVA
Some application cases of regular expressions
The above is the detailed content of The use of regular expressions in angularJS. For more information, please follow other related articles on the PHP Chinese website!