时间:2021-07-01 10:21:17 帮助过:8人阅读
<!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>
相关推荐:
正则表达式的一些应用案例
以上就是angularJS之正则表达式的运用的详细内容,更多请关注Gxl网其它相关文章!