-
Notifications
You must be signed in to change notification settings - Fork 55
/
01-1-forms.html
47 lines (40 loc) · 1.9 KB
/
01-1-forms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<!--This is a modified version of the form demonstration on https://docs.angularjs.org/guide/forms-->
<head>
<title>Formsdemo</title>
<style>
*{font-family: Tahoma; font-size: 1em;}#wrapper{width:100%;};
#inner{width:50%; margin:0 auto; border:solid black 1px;};
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js"></script>
<script>
//we don't need any fancy module creation here
function Frm($scope){
$scope.data = {};
}
</script>
</head>
<body ng-app>
<div id="inner" ng-controller="Frm">
<form name="myForm" novalidate id="f">
<!--novalidate disables default browser based validation-->
Name: <input type="text" ng-model="data.user.name" name="name" required><br />
Email: <input type="email" ng-model="data.user.email" name="email" required><br />
<!--Demonstrates the $error.required and $error.email validation-->
<span ng-show="myForm.email.$error.required">Email is required (only shown if you don't type any email)</span><br />
<span ng-show="myForm.email.$error.email">This is not an email! (shown if you type in invalid email)</span><br />
<input type="checkbox" ng-model="data.user.toc" name="toc" required>Do you agree that we have NO Terms and Conditions<br />
<!--Demonstrates difference between ng-hide and ng-show-->
<div ng-hide="data.user.toc">Please agree to TOCs!</div>
<div ng-show="data.user.toc">Thank you for signing!</div><br />
Type in a message to introduce yourself!<input type="text" ng-model="data.user.message" name="message" ng-model-options="{ debounce: 250 }"><br />(this demonstrated delayed triggers using ng-model-options)
</form>
<br />
<!--Demonstrates the use of logical evaluators in display of data-->
<span ng-show="myForm.name.$valid && myForm.email.$valid && myForm.toc.$valid">
You entered: {{data.user.name}} and {{data.user.email}} with message {{data.user.message}}
</span>
</div>
</body>
</html>