angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

input type="number" is valid when a non numeric value is entered in IE 11

Open brik opened this issue 12 years ago • 8 comments

When entering text or a combination of text and numbers, form.number.$valid" does not always validate to false.

Examples: "ddd" validates to true (not OK) "ddd3" validates to true (not OK) "3ddd" validates to false "33" validates to true

When using the required attribute, it works as expected.

Tested OK in Chrome and Firefox 28.0

Plnkr: http://plnkr.co/edit/uqOkCPxNYQWg8xog1IKi?p=preview

Looks like it is a similar issue to #2144

brik avatar Apr 10 '14 11:04 brik

I can look into this later today (but if you can debug this, I would suggest looking at this glob of text, this is probably where the problem is)

caitp avatar Apr 10 '14 11:04 caitp

It seems to enter the if statement from the glob in both Chrome and IE, but the ValidityState object is different in IE. I don't know if this helps at all...

Chrome ValidityState badInput: true valid: false

IE 11 ValidityState badInput: false valid: true

brik avatar Apr 10 '14 12:04 brik

If you're entering letters in a number input, and IE is not setting badInput to true, then they're not behaving consistently with the spec (for better or worse, some of the things in that spec are kind of nonsense). But even so, the regexp should be invalidating it.

caitp avatar Apr 10 '14 12:04 caitp

My bad @ badInput, I was testing this inside an ng-grid and got slightly different results there, outside the grid badInput is undefined. Same behavior still though.

brik avatar Apr 10 '14 13:04 brik

I can confirm that this is happening.

Unfortunate as it is, I don't think there's much we can really do about it. IE is not doing the right thing here. All we see is the empty string, and we get no way to know that the string is empty due to an error. That's too bad.

On Thu, Apr 10, 2014 at 9:17 AM, brik [email protected] wrote:

My bad @ badInput, I was testing this inside an ng-grid and got slightly different results there, outside the grid badInput is undefined. Same behavior still though.

Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.js/issues/7070#issuecomment-40078139 .

caitp avatar Apr 10 '14 13:04 caitp

Ok, that's a shame. Thanks for looking into it anyway.

brik avatar Apr 14 '14 09:04 brik

I don't think this is really fixable on Angular's side, but I have raised an issue about this with MS at https://connect.microsoft.com/IE/feedback/details/850187/html5-constraint-validation-is-broken-in-ie11-for-input-type-number --- If people +1 it, maybe that could be fixed for the next iteration. I don't know.

I will leave this issue open and possibly revisit it later

caitp avatar May 22 '14 01:05 caitp

Tracked in https://github.com/angular/angular.js/issues/10981 with more info

Narretz avatar Jun 06 '15 11:06 Narretz