Form is marked as valid when required fields are not dirty
See original GitHub issueI recorded the behavior here:
The first 3 fields of this form are required, and the form still returns true for isValid
until the field is dirty.
Is there an option that I’m missing to configure the form to be considered invalid until the fields are actually touched & filled in?
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
angular - required reactive form control is invalid while pristine
The control is invlid when the form is initiate, while it is still pristine, not touched and not dirty. Is there any assumption...
Read more >Styling Form Inputs in CSS With :required, :optional, :valid and
We can use the :required , :optional , :valid and :invalid pseudo-classes coupled with HTML5 form validation attributes like required or pattern ...
Read more >Valid and Invalid in Angular Forms | by Garen Stepanyan
In Angular one of most common ways to validate forms is to disable the submit button. It's a nice way (alongside with helpful...
Read more >AbstractControl - Angular
A control is dirty if the user has changed the value in the UI. touched: boolean, Read-Only. True if the control is marked...
Read more >What's the difference between ng-pristine and ng-dirty in ...
Return type: Return Boolean True if the form/input field is not modified by the user else it returns False. ng-dirty: The ng-dirty class ......
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
@foxhound87 I think that even when the form is “cleared” the “isValid” property should remain false until the form is actually valid. That’s the only way that it makes sense in my head 😃
Thank you for the fix.
Cheers 🎉
I just plugged in the devtools and recorded another video. There’s 100% nothing wrong with the submit button because the implementation is pretty simple:
Here’s the video with devtools (which btw are a genius addition 😱): http://jmp.sh/Q9unDRE
You can see that
isValid
is always true unless a field is dirty. It should befalse
until all therequired
fields are valid.