Created
July 1, 2013 22:09
-
-
Save afitterling/5905057 to your computer and use it in GitHub Desktop.
Confirmation Validation <input name="xxx" ............>
<input name="confirm_xxx" confirmationValidation="xxx" ..............>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('confirmationValidation', function () { | |
return { | |
require: 'ngModel', | |
link: function (scope, elm, attrs, ctrl) { | |
var field = attrs.confirmationValidation // || ''; should contain input field (binding: name="xxx") to use as confirm validation | |
ctrl.$parsers.unshift(function (viewValue, $scope) { | |
var noMatch = viewValue != scope.signUpForm[field].$viewValue | |
ctrl.$setValidity('noMatch', !noMatch) | |
}) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment