29.模板式邮箱验证
2017-05-31 10:45 笨笨03 阅读(1452) 评论(0) 编辑 收藏 举报 1 <!DOCTYPE html>
2 <html>
3 <head lang="en">
4 <meta charset="UTF-8">
5 <title>T6-邮箱验证</title>
6 <script src="js/angular.js"></script>
7 </head>
8 <body>
9 <h2>Validation Example</h2>
10 <form ng-app="myApp" ng-controller="tom"
11 name="myForm" novalidate>
12
13 <p>用户名:<br>
14 <input type="text" name="user" ng-model="user" required>
15 <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
16 <span ng-show="myForm.user.$error.required">用户名是必须的。</span>
17 </span>
18 </p>
19
20 <p>邮箱:<br>
21 <input type="email" name="email" ng-model="email" required>
22 <span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
23 <span ng-show="myForm.email.$error.required">邮箱是必须的。</span>
24 <span ng-show="myForm.email.$error.email">非法的邮箱。</span>
25 </span>
26 </p>
27
28 <p>
29 <input type="submit"
30 ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
31 myForm.email.$dirty && myForm.email.$invalid">
32 </p>
33
34 </form>
35
36 <script>
37 var app = angular.module('myApp', []);
38 app.controller('tom', function($scope) {
39 $scope.user = '中国';
40 $scope.email = 'john@gmail.com';
41 });
42 </script>
43
44 </body>
45 </html>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>T6-邮箱验证</title>
<script src="js/angular.js"></script>
</head>
<body>
<h2>Validation Example</h2>
<form ng-app="myApp" ng-controller="tom"
name="myForm" novalidate>
<p>用户名:<br>
<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">用户名是必须的。</span>
</span>
</p>
<p>邮箱:<br>
<input type="email" name="email" ng-model="email" required>
<span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid">
<span ng-show="myForm.email.$error.required">邮箱是必须的。</span>
<span ng-show="myForm.email.$error.email">非法的邮箱。</span>
</span>
</p>
<p>
<input type="submit"
ng-disabled="myForm.user.$dirty && myForm.user.$invalid ||
myForm.email.$dirty && myForm.email.$invalid">
</p>
</form>
<script>
var app = angular.module('myApp', []);
app.controller('tom', function($scope) {
$scope.user = '中国';
$scope.email = 'john@gmail.com';
});
</script>
</body>
</html>