aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/web/gui/src/main/webapp/_sdh/ng-examples/ch04-05-form-validation.html
blob: 3501adb139536e7beec9567dc07c8e72f63228df (plain)
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
<!DOCTYPE html>
<html ng-app="notesApp">
<head>
    <title>Notes App</title>
    <script src="../../tp/angular.js"></script>
    <style>
        span {
            background-color: #cce;
        }
    </style>
</head>
<body ng-controller="MainCtrl as ctrl">

<form ng-submit="ctrl.submit()" name="myForm">
    <input type="text"
           placeholder="username"
           ng-model="ctrl.user.username"
           required
           ng-minlength="4"/>

    <input type="password"
           placeholder="password"
           ng-model="ctrl.user.password"
           required/>

    <input type="submit"
           value="Submit"
           ng-disabled="myForm.$invalid"/>
</form>

<script type="text/javascript">
    angular.module('notesApp', [])
        .controller('MainCtrl', [function () {
            var self = this;
            self.submit = function () {
                console.log('Submit: ', self.user);
            };
        }]);
</script>

</body>
</html>