29.模板式邮箱验证

 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>
View Code
<!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>

转载于:https://www.cnblogs.com/mx2036/p/6923021.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值