diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 24bf1a8030fe..750c31f3f35e 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -1230,7 +1230,7 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
return value;
});
- if (attr.min || attr.ngMin) {
+ if (isDefined(attr.min) || attr.ngMin) {
var minVal;
ctrl.$validators.min = function(value) {
return ctrl.$isEmpty(value) || isUndefined(minVal) || value >= minVal;
@@ -1246,7 +1246,7 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
});
}
- if (attr.max || attr.ngMax) {
+ if (isDefined(attr.max) || attr.ngMax) {
var maxVal;
ctrl.$validators.max = function(value) {
return ctrl.$isEmpty(value) || isUndefined(maxVal) || value <= maxVal;
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index f034172246bd..b478e60a84a8 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -4211,12 +4211,17 @@ describe('input', function() {
});
it('should validate even if min value changes on-the-fly', function() {
- scope.min = 10;
+ scope.min = undefined;
compileInput('');
+ expect(inputElm).toBeValid();
changeInputValueTo('15');
expect(inputElm).toBeValid();
+ scope.min = 10;
+ scope.$digest();
+ expect(inputElm).toBeValid();
+
scope.min = 20;
scope.$digest();
expect(inputElm).toBeInvalid();
@@ -4252,12 +4257,17 @@ describe('input', function() {
});
it('should validate even if the ngMin value changes on-the-fly', function() {
- scope.min = 10;
+ scope.min = undefined;
compileInput('');
+ expect(inputElm).toBeValid();
changeInputValueTo('15');
expect(inputElm).toBeValid();
+ scope.min = 10;
+ scope.$digest();
+ expect(inputElm).toBeValid();
+
scope.min = 20;
scope.$digest();
expect(inputElm).toBeInvalid();
@@ -4294,12 +4304,17 @@ describe('input', function() {
});
it('should validate even if max value changes on-the-fly', function() {
- scope.max = 10;
+ scope.max = undefined;
compileInput('');
+ expect(inputElm).toBeValid();
changeInputValueTo('5');
expect(inputElm).toBeValid();
+ scope.max = 10;
+ scope.$digest();
+ expect(inputElm).toBeValid();
+
scope.max = 0;
scope.$digest();
expect(inputElm).toBeInvalid();
@@ -4335,12 +4350,17 @@ describe('input', function() {
});
it('should validate even if the ngMax value changes on-the-fly', function() {
- scope.max = 10;
+ scope.max = undefined;
compileInput('');
+ expect(inputElm).toBeValid();
changeInputValueTo('5');
expect(inputElm).toBeValid();
+ scope.max = 10;
+ scope.$digest();
+ expect(inputElm).toBeValid();
+
scope.max = 0;
scope.$digest();
expect(inputElm).toBeInvalid();