Skip to content

Commit 58ac268

Browse files
author
Joe Enzminger
committed
bug($ng): change numberInputType to check for leading decimals
add check for leading decimal. Some browsers swallow leading decimals on input type="number". fixes angular#5680
1 parent 1c045f1 commit 58ac268

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ng/directive/input.js

+4
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
534534
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
535535

536536
ctrl.$parsers.push(function(value) {
537+
//on some browsers, '.' evaluates to NaN which prevents input of leading decimals
538+
if (value === '.') {
539+
value = '0.';
540+
}
537541
var empty = ctrl.$isEmpty(value);
538542
if (empty || NUMBER_REGEXP.test(value)) {
539543
ctrl.$setValidity('number', true);

0 commit comments

Comments
 (0)