Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5af9454

Browse files
committed
feat(input): use ValidityState for required state
Change NgModelController $isEmpty method to consider HTML5 constraint validation in supporting browsers, fallback to normal empty data check
1 parent 1192531 commit 5af9454

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ng/directive/input.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,12 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
16131613
* @returns {boolean} True if `value` is empty.
16141614
*/
16151615
this.$isEmpty = function(value) {
1616-
return isUndefined(value) || value === '' || value === null || value !== value;
1616+
var validity = $element.prop('validity');
1617+
if (isObject(validity)) {
1618+
return validity.valueMissing;
1619+
} else {
1620+
return isUndefined(value) || value === '' || value === null || value !== value;
1621+
}
16171622
};
16181623

16191624
var parentForm = $element.inheritedData('$formController') || nullFormCtrl,

0 commit comments

Comments
 (0)