From ef9492405800000c88051b4824a0c1f893d7a628 Mon Sep 17 00:00:00 2001 From: Alexey Kudinkin Date: Wed, 20 Aug 2014 11:44:35 +0400 Subject: [PATCH] Fix for #8234 --- src/ng/directive/input.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 7acf65596a45..70ac0d41ccec 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -2333,11 +2333,13 @@ var maxlengthDirective = function() { var maxlength = 0; attr.$observe('maxlength', function(value) { maxlength = int(value) || 0; + if (!angular.isDefined(ctrl.$validators.maxlength)) { + ctrl.$validators.maxlength = function(value) { + return ctrl.$isEmpty(value) || value.length <= maxlength; + }; + } ctrl.$validate(); }); - ctrl.$validators.maxlength = function(value) { - return ctrl.$isEmpty(value) || value.length <= maxlength; - }; } }; }; @@ -2352,11 +2354,13 @@ var minlengthDirective = function() { var minlength = 0; attr.$observe('minlength', function(value) { minlength = int(value) || 0; + if (!angular.isDefined(ctrl.$validators.minlength)) { + ctrl.$validators.minlength = function(value) { + return ctrl.$isEmpty(value) || value.length >= minlength; + }; + } ctrl.$validate(); }); - ctrl.$validators.minlength = function(value) { - return ctrl.$isEmpty(value) || value.length >= minlength; - }; } }; };