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.

Don't show errors until field is blurred?

See original GitHub issue

It was hard to come up with a good title for this, sorry.

I’m essentially interested in a feature of redux-form that let’s us not show an error on a field unless the field received a blur event or the user submitted the form. This leads to less noise when filling out an empty form, as the user can enter data without being nagged by error displays while typing.

Main use case: Entering e.g. an email-address (or phone numbers or addresses). With mobx-forms, as soon as the users starts to type, the field is touched and has errors and we hence display those errors.

With redux-forms, however, touched is only set after the field receives a blur event or the form is submitted (the field is validated in any case, though). This allows us to only show the error after the user is done with the field.

There’s a visited flag that is similar to mobx-form’s touched.

Here’s a demo that shows the behavior (the redux devtools chrome extension is handy here, as it can display the whole state):

http://redux-form.com/6.6.0/examples/syncValidation/

Just start typing in the email field and compare it to how mobx-forms handles this use case.

Empty form:

bildschirmfoto 2017-03-29 um 16 29 12

Starting to type (no error is shown, although there is one in the state):

bildschirmfoto 2017-03-29 um 16 30 40 bildschirmfoto 2017-03-29 um 16 34 35 bildschirmfoto 2017-03-29 um 16 29 59

(note that there is an error, but no touched)

Pressing <tab> moves to the next field and shows the error:

bildschirmfoto 2017-03-29 um 16 30 45 bildschirmfoto 2017-03-29 um 16 30 25

To close, I’m also fine with having to implement this stuff on my side, I’m just very unsure of how to best do that. Any pointers appreciated!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nuschkcommented, Mar 31, 2017

interacted is certainly better than edited. Yeah, it’s not crystal clear either, but, well, naming is hard.

You could also name it by its purpose and thus showError and put it next to hasError. This way, of course, it could only ever be true if the field has errors.

1reaction
nuschkcommented, Mar 31, 2017

@foxhound87 I agree with naming that prop touched is misleading. I find your definition much less confusing. edited is not really better, though, so I’m still looking for a better name… 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show form error without field blur in angular - Stack Overflow
But if I click on some fields and blur, then it will show the error for that field. How can I make the...
Read more >
Validate on blur or keypress? - UX Stack Exchange
If you validate on blur, show a simple non-obtrusive error (a highlight and possible a short message next to or under the field)....
Read more >
Designing Better Inline Validation UX - Smashing Magazine
The most common type of inline validation is late validation: we validate input once a user has left the input field (on blur...
Read more >
Form Validation: You want :not(:focus):invalid, not - Bram.us
I prefer when forms wait for blur before freaking out ... .error-message { display: none; } input:not(:focus):invalid { border-color: ...
Read more >
Fixing Vuetify's Form Validation. Quite ... - Robert Mirabelle
The reason this occurs is because clicking on any other control or link on the page causes blur() to be fired on the...
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