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

ngMaxLength with integer only input fails #7848

Closed
pocesar opened this issue Jun 16, 2014 · 12 comments
Closed

ngMaxLength with integer only input fails #7848

pocesar opened this issue Jun 16, 2014 · 12 comments

Comments

@pocesar
Copy link
Contributor

pocesar commented Jun 16, 2014

ngMaxlength seem to be coercing the input value to int? I have

<input ng-model="user.data.numero" ng-maxlength="8" type="text">

which user.data.numero = 232, and it's failing. if I type "n232" it works. Using latest 1.3.0 beta 12

@Narretz
Copy link
Contributor

Narretz commented Jun 16, 2014

Hm, in this plunker, $error.maxlength becomes true if I have more than 8 characters in the input:

http://plnkr.co/edit/od2qLXAncyy73FAdqlng?p=preview

So this works. Are your refering to a specific behavior? (In beta.12, the behavior changed insofar that invalid model values will show in the bound input regardless of validity.)

@matsko
Copy link
Contributor

matsko commented Jun 16, 2014

@Narretz you mean that when the validity is failing then the model value will not show up at all.

http://plnkr.co/edit/it2bJvUwaT3VAy2idGQS?p=preview

@matsko matsko added this to the 1.3.0-beta.13 milestone Jun 16, 2014
@matsko matsko self-assigned this Jun 16, 2014
@Narretz
Copy link
Contributor

Narretz commented Jun 16, 2014

@matsko that has always been the case, iirc. The other way round is new (invalid model shows in input). Might actually be a breaking change if you think about it.

@matsko
Copy link
Contributor

matsko commented Jun 16, 2014

Yes it could be overly strict. I think we need another property on ngModel that is there no matter what: #6740 (comment)

@tbosch
Copy link
Contributor

tbosch commented Aug 4, 2014

The example above has a mistake: It should be <input type="number">, see here: http://plnkr.co/edit/FPYKrOrTrWKf6PnoaYro?p=preview

Initially, there is no validation error. But when you change the number, the model value gets cleared and the validation error is shown. So this is a legit bug!

@tbosch
Copy link
Contributor

tbosch commented Aug 4, 2014

Might be fixed via #7968 though...

@caitp
Copy link
Contributor

caitp commented Aug 4, 2014

That PR should fix it, but it's a good point that it doesn't really make sense for numbers, in general, but it might be good to support for url/email.

@matsko
Copy link
Contributor

matsko commented Aug 4, 2014

The bug is fixed when tested on master: http://plnkr.co/edit/0HKYThxJWZIoHvQIgaol?p=preview

@caitp
Copy link
Contributor

caitp commented Aug 4, 2014

the bug is still happening there with the snapshot script, @matsko

@matsko
Copy link
Contributor

matsko commented Aug 4, 2014

Sorry, my mistake, I though that we were paying attention to the error and not the model value.

@caitp
Copy link
Contributor

caitp commented Aug 8, 2014

well, there's a fix for this but I haven't heard any comments about it =( moving this to the next milestoneeeeee

@caitp caitp modified the milestones: 1.3.0-beta.18, 1.3.0-beta.19 Aug 8, 2014
@matsko matsko modified the milestones: 1.3.0-beta.19, 1.3.0 Aug 18, 2014
@Narretz Narretz changed the title ngMaxLength with integer only input fails ngMaxLength on type="text" with integer only input fails Aug 28, 2014
@Narretz Narretz changed the title ngMaxLength on type="text" with integer only input fails ngMaxLength with integer only input fails Aug 28, 2014
@Narretz
Copy link
Contributor

Narretz commented Sep 24, 2014

As far as I can see the bug in http://plnkr.co/edit/FPYKrOrTrWKf6PnoaYro?p=preview is fixed in the current snapshot.

@Narretz Narretz closed this as completed Sep 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.