<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<script data-require="angular.js@1.2.16" data-semver="1.2.16" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script data-require="jquery@*" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script data-require="bootstrap@*" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="http://rawgit.com/Lemoncode/lc-validation-summary/master/build/lcvalidationsummary.js"></script>
<script src="http://rawgit.com/Lemoncode/lc-validation-summary/master/build/lcvalidationSummary-tpl.js"></script>
<script src="app.js"></script>
<link rel="stylesheet" href="http://rawgit.com/Lemoncode/lc-validation-summary/master/build/lcValidationSummary.css" />
</head>
<body ng-app="sampleApp" ng-controller="sampleController" lc-validations-container="">
<form name="userForm">
<label for="entryScreenEmail">Email</label>
<input id="entryScreenEmail"
class="form-control"
type="email"
placeholder="Email"
name="entryScreenEmail"
ng-model="model.email"
lc-validation-bubble=""
validation-friendly-name="Email"
ng-required="true"
checkvalidationemail="" />
<label for="entryScreenConfirmationEmail">Confirm Email*</label>
<input id="entryScreenConfirmationEmail"
class="form-control"
type="email"
placeholder="Confirm Email"
name="entryScreenConfirmationEmail"
ng-model="model.confirmationEmail"
lc-validation-bubble=""
validation-friendly-name="Confirm Email"
fieldtomatchmodelproperty="model.email"
checktwofieldsmatch="true"
checkvalidationemail=""
fieldtomatch="model.email" />
</form>
<div lc-validation-summary=""></div>
</body>
</html>
var sampleApp = angular.module('sampleApp', ['lcValidationSummary'])
.controller('sampleController', ['$scope', function sampleController($scope){
$scope.model = {
email:"",
confirmationEmail:""
}
}]).directive('checktwofieldsmatch', function () {
return {
require: ["ngModel", "^form"],
scope: {
fieldtomatchmodelproperty: '@',
fieldtomatch: '='
},
link: function (scope, elm, attrs, ctrl) {
var currentControl = ctrl[0];
var currentForm = ctrl[1];
var emailMustMatch = function (email, confirmEmail) {
return (email === confirmEmail);
};
currentControl.$parsers.unshift(function (viewValue) {
if (typeof (viewValue != "undefined")) {
currentControl.$setValidity('checktwofieldsmatch', emailMustMatch(scope.fieldtomatch, viewValue));
}
return viewValue;
});
var propertyToWatch = scope.fieldtomatchmodelproperty;
scope.$parent.$watch(propertyToWatch, function (value, lastValue) {
if (typeof (currentControl.$viewValue != "undefined")) {
currentControl.$setValidity('checktwofieldsmatch', emailMustMatch(value, currentControl.$viewValue));
}
});
}
};
}).config(['validationContainerServiceProvider', function(validationContainerServiceProvider){
validationContainerServiceProvider.addValidation({ type: 'checktwofieldsmatch', friendlyDescription: 'The fields must match' });
}]);
Sample code for the [lcValidationSummary](http://lemoncode.github.io/lc-validation-summary/) tutorial.