-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.js
More file actions
42 lines (35 loc) · 1.36 KB
/
Copy pathvalidation.js
File metadata and controls
42 lines (35 loc) · 1.36 KB
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
(function (angular) {
'use strict';
var app = angular.module('ngValidationForm', ['ui.bootstrap', 'ngMessages'])
app.controller('validationController', ['$scope', function ($scope) {
$scope.ValidationMessage = "";
$scope.submit = function (isValid) {
// check to make sure the form is completely valid
if (isValid) {
alert("Valid");
}
else {
alert("Invalid fields found!");
}
};
}]);
//https://github.com/angular/angular.js/wiki/Understanding-Directives
app.directive('myPasswordVerify', [function () {
return {
require: 'ngModel',
scope:'true',
link: function (scope, element, attributes, aController) {
var verifyPasswd = function () {
// Get password from ng-model
var passwd1 = scope.$eval(attributes.ngModel);
//get the value of the other password
var passwd2 = scope.$eval(attributes.myPasswordVerify);
return passwd1 == passwd2;
};
scope.$watch(verifyPasswd, function (validity) {
aController.$setValidity("passverified", validity);
});
}
}
}]);
})(window.angular);