You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular input validation not in sync with HTMLInputElement validity #26787
Enter "asdf" in the input
Expected: Native and Angular should both display false
Actual: Native displays false, Angular displays true
What is the motivation / use case for changing the behavior?
Consistent input validation. Currently entering "10,000,000" in numeric field renders to null value through ngModel (parseFloat) binding and user gets no error feedback.
I'm still reading issues (there are a lot of them!) but I don't understand why this isn't built-in behavior. "Native element is invalid" should be an error case for all template form controls, out of the box, automatically. The exact example you posted -- where test.validity.valid is false but testModel.valid is true -- should never happen.
Is there a good argument against adding a default validation to all NgModel.control instances exactly like this?
Activity
PRR24 commentedon Oct 28, 2018
To work around the issue, one can use better/different ControlValueAccessor. For simpler use cases, simple workaround would probably be sufficient:
thw0rted commentedon Nov 13, 2018
I'm still reading issues (there are a lot of them!) but I don't understand why this isn't built-in behavior. "Native element is invalid" should be an error case for all template form controls, out of the box, automatically. The exact example you posted -- where
test.validity.validis false buttestModel.validis true -- should never happen.Is there a good argument against adding a default validation to all
NgModel.controlinstances exactly like this?thw0rted commentedon Nov 13, 2018
Also, trackbacks to #16352, #17491, #23635.
angular-automatic-lock-bot commentedon Sep 14, 2019
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.