TheSharpieOne/angular-validation-match

Number Input type will not match.

Closed this issue · 3 comments

I am not able to get number input types to match.
To see a working example use the fiddle out of the README file and change the input types from password to number it will not work.

Hmmm, it seems it will always use the view value for the input with this directive on it, which will always be a string. Then it will compare that string to the other input, which internally is a number. And "1" !== 1.
A quick solution would be to validate against the $viewValue shown in the input, if possible (if you are using a form) (See the last section of the README). This will match string to string. See: http://jsfiddle.net/TheSharpieOne/qs9bhgcn/
I'll look to see if I can fix this without causing issues (I forget why I used the view value like this, it may be for a reason or maybe not).

Thanks the quick solution worked for me.

As far as I can tell, using the $viewValue of the input with the directive on it is a carryover from before Angular 1.3 (when $parsers and $formatters were used, before $validator was a thing).
I changed it to use modelView || viewValue so it should prefer the internal value, which in this case is a number instead of a string.