diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index fa6fe55d9f5e..d8ec82606555 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -2189,7 +2189,7 @@ var maxlengthDirective = function() { ctrl.$validate(); }); ctrl.$validators.maxlength = function(value) { - return ctrl.$isEmpty(value) || value.length <= maxlength; + return ctrl.$isEmpty(value) || value.toString().length <= maxlength; }; } }; @@ -2207,7 +2207,7 @@ var minlengthDirective = function() { ctrl.$validate(); }); ctrl.$validators.minlength = function(value) { - return ctrl.$isEmpty(value) || value.length >= minlength; + return ctrl.$isEmpty(value) || value.toString().length >= minlength; }; } }; diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index e48a2a082672..bd315a522bbc 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -1400,6 +1400,11 @@ describe('input', function() { changeInputValueTo('aaa'); expect(inputElm).toBeValid(); + + scope.$apply(function() { + scope.value = 1234; + }); + expect(inputElm).toBeValid(); }); it('should listen on ng-minlength when minlength is observed', function() { @@ -1446,6 +1451,11 @@ describe('input', function() { changeInputValueTo('aaa'); expect(inputElm).toBeValid(); + + scope.$apply(function() { + scope.value = 42; + }); + expect(inputElm).toBeValid(); }); it('should listen on ng-maxlength when maxlength is observed', function() {