question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form is marked as valid when required fields are not dirty

See original GitHub issue

I recorded the behavior here:

http://jmp.sh/xPvhIyH

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:closed
  • Created 7 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kitzecommented, Jan 6, 2017

@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 🎉

1reaction
kitzecommented, Jan 5, 2017

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:

<SubmitButton
  disabled={form.isValid === false}
/>

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 be false until all the required fields are valid.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found