Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

mdForm mdInputContainer should show error after user touching a field #1267

Closed
SanderElias opened this issue Jan 23, 2015 · 4 comments
Closed

Comments

@SanderElias
Copy link
Contributor

I created this sample on plunker to demonstrate a few issues I'm having with forms.

When you enter the form, and tab through the fields, without actually changing anything, errors should be thrown. Now the errors are only shown after a user changes a field. Validations should be verified on blur.

@ThomasBurleson ThomasBurleson added this to the 0.8.0 milestone Jan 23, 2015
@EladBezalel
Copy link
Member

@ThomasBurleson I think 0.7.1 is the milestone you should label this, the error validation is assigned there..

@ajoslin
Copy link
Contributor

ajoslin commented Jan 24, 2015

Yeah, this is a big question. I arbitrarily decided that the errors should appear red after the form is invalid and dirty.
Making it red after the form is touched & invalid sounds better.

We should provide a way to customize this, though. Thoughts on an API?

<md-input-container md-errored="myInput.$invalid">
  <input name="myInput">
</md-input-container>

md-errored would default to myInput.$invalid && myInput.$touched.

@SanderElias
Copy link
Contributor Author

@ajoslin Well, the color should be the alert color for the theme right? And an error should be in that color, so there is no issue there. (I have an issue with them appearing before the users touched a field, but I separated that one out #1266)

I think the md-errored api is a good idea, as long as indeed the default is $invalid && $touched. If an field is invalid, and a user has touched the field, the error should be visible. In the current situation, an user can tab trough the entire form without getting a clue something is off. I don't think that is a good idea.

@gkalpak
Copy link
Member

gkalpak commented Jan 25, 2015

IMO, errors should always be displayed as errors (i.e. red or whatever color indicates an error). The developer should decide when to show the errors (e.g. ngIf="myInput.$touched").

Providing a sensible default for that and allowing the developer to customize it, would be ideal. E.g.:

<md-input-container md-show-errors="myInput.$dirty">...</md-input-container>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants