diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 7b0412bd80e8..2f39fc60214c 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -584,7 +584,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
if (attr.ngMinlength) {
var minlength = int(attr.ngMinlength);
var minLengthValidator = function(value) {
- return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length >= minlength, value);
+ return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.toString().length >= minlength, value);
};
ctrl.$parsers.push(minLengthValidator);
@@ -595,7 +595,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
if (attr.ngMaxlength) {
var maxlength = int(attr.ngMaxlength);
var maxLengthValidator = function(value) {
- return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value);
+ return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.toString().length <= maxlength, value);
};
ctrl.$parsers.push(maxLengthValidator);
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index d14e1a2601c0..b67ada993091 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -761,6 +761,16 @@ describe('input', function() {
changeInputValueTo('aaa');
expect(scope.value).toBe('aaa');
});
+
+ it('should use string representation of the value', function(){
+ compileInput('');
+
+ scope.$apply(function() {
+ scope.value = 123;
+ });
+
+ expect(inputElm).toBeValid();
+ });
});
@@ -775,6 +785,16 @@ describe('input', function() {
changeInputValueTo('aaa');
expect(scope.value).toBe('aaa');
});
+
+ it('should use string representation of the value', function(){
+ compileInput('');
+
+ scope.$apply(function() {
+ scope.value = 123;
+ });
+
+ expect(inputElm).toBeValid();
+ });
});