Skip to content

Instantly share code, notes, and snippets.

@afitterling
Created July 1, 2013 22:09
Show Gist options
  • Save afitterling/5905057 to your computer and use it in GitHub Desktop.
Save afitterling/5905057 to your computer and use it in GitHub Desktop.
Confirmation Validation <input name="xxx" ............> <input name="confirm_xxx" confirmationValidation="xxx" ..............>
.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