md-input type="number" required does not update control validation state
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
A required but empty md-input field should turn the control invalid.
What is the current behavior?
Has the input been touched once it’s valid
prop stays true
even if the the input is empty.
What are the steps to reproduce?
Enter a number and remove it again. Here is a plunker.
What is the use-case or motivation for changing an existing behavior?
Validating forms should be working.
Which versions of Angular, Material, OS, browsers are affected?
Tested with: angular: ‘@2.0.0-rc.4’ forms: ‘@0.2.0’ material: ‘@2.0.0-alpha.6’ Chomre 52.0.2743.82
Is there anything else we should know?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Input type number "only numeric value" validation
The problem is when a user enters something that is not a number ("123e" or "abc") the FormControl's value becomes null , keep...
Read more ><input type="number"> - HTML: HyperText Markup Language
A number input is considered valid when empty and when a single number is entered, but is otherwise invalid. If the required attribute...
Read more >Working with Angular 4 Forms: Nesting and Input Validation
Forms in Angular applications can aggregate the state of all inputs that are under that form and provide an overall state like the...
Read more >Validating Input | Web Accessibility Initiative (WAI) - W3C
HTML5 defines a range of built-in functionality to validate common types of input, such as email addresses and dates. In some situations, such...
Read more >Validating form input - Angular
Every time the value of a form control changes, Angular runs validation and generates either a list of validation errors that results in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve experienced this as well.
I think the issue is related to the value of a number input being
NaN
when the field is empty.As a temporary workaround, I wrote a custom validator to handle this case. Here’s an example:
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.