I am one of those that have already pointed out that it is broken.
After some more digging it seems to me that the HTML 5 standard and 
Chrome's (compliant) implementation is to blame. (The problem does not 
exist (yet) in Firefox.)

If the input does not contain a valid number, then there seems to be no way 
to retrieve the _actual, invalid_ contents of the field.
(The only option I have seen so far is to select the text via JS and query 
the selection, but of course you don't want to do that while just 
validating.)
I think there's a usability bug in the HTML spec, that says that for 
invalid input the fields value should be the empty string.
If the form (or the input) has "novalidate" attribute set, then JS should 
get the real, invalid input, so that validation using JS is possible.

However a workaround using an additional custom directive is mentioned here:
https://groups.google.com/d/topic/angular/pRc5pu3bWQ0/discussion
see
http://plnkr.co/edit/q0HmACwbyYMioat0oRSv?p=preview
No idea if the property that is tested is in any way standardized or 
specific to Chrome.

On Saturday, January 25, 2014 1:22:47 AM UTC+1, Mark Volkmann wrote:
>
> I have been digging into AngularJS support for form validation lately. I 
> really like it except for one thing. It seems that validation of <input 
> type="number" name="foo"> is broken. A bit of googling for this issue 
> reveals that many people agree that it is broken. Is this something that is 
> on the radar to fix?
>
> What I mean specifically is that myFormName.foo.$error.number will not be 
> set when a non-number is entered in the input. Also, myFormName.foo.$valid 
> and myFormName.foo.$invalid are not set.
>
> -- 
> R. Mark Volkmann
> Object Computing, Inc. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to