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

input[number] validation error if modelvalue is undefined #9245

Closed
robbro opened this issue Sep 24, 2014 · 2 comments
Closed

input[number] validation error if modelvalue is undefined #9245

robbro opened this issue Sep 24, 2014 · 2 comments

Comments

@robbro
Copy link

robbro commented Sep 24, 2014

In form1 the number validator will report "Not a number" even though modelvalue is not required and is undefined. If modelvalue is null (form2) the number validator error is not present. I'd expect no validation error in form1 since modelvalue is not required, is this a bug or am I missing something?

Note: If I remove "ng-required=false" from input in form1 there are no validation errors.

Angular Version(s): AngularJS 1.3.0 rc3
Browsers: Firefox and Chrome latest
Plunker: http://plnkr.co/edit/gCZhWaTLgdJLgXoJs0Nu?p=preview

<form name="form1">
   <input type="number" id="field1" name="field1" ng-model="undefinedModelvalue" ng-required="false">
   <span ng-show="form1.field1.$error.number">Not a number</span>
   <span ng-show="form1.field1.$error.required">Required</span>
</form>
<form name="form2">
   <input type="number" id="field1" name="field1" ng-model="nullModelvalue" ng-required="false">
   <span ng-show="form2.field1.$error.number">Not a number</span>
   <span ng-show="form2.field1.$error.required">Required</span>
</form>
@gkalpak
Copy link
Member

gkalpak commented Sep 24, 2014

This is a duplicate of #9106.

@caitp
Copy link
Contributor

caitp commented Sep 24, 2014

Thanks @gkalpak --- closing this as a duplicate, I am looking at 9106 today

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants