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
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
The only class available on md-input is .md-focused
If the current behavior is a bug,
please provide steps to reproduce and if possible a minimal demo of the problem
via https://plnkr.co or similar.
What is the expected behavior?
It would be great if the classes of ngControl could be transfered to the md-input label and the md-input underline, in order to display live return on the validity of inputs
What is the motivation / use case for changing the behavior?
Better User experience
Which version of Angular and Material, and which browser and OS does this issue affect?
Did this work in previous versions of Angular / Material?
Please also test with the latest stable and snapshot versions.
Other information
(e.g. detailed explanation, stacktraces, related issues, suggestions how to fix)
Reacted by Dzmitry Shylovich, Jianming Xiao, Renan Ferreira, Joe VanWanzeele, Tomasz Bak, Leo Caseiro, Andžej Maciusovič, KingTigerXCII, Wojciech, Roy and 14 more
How to divider color for md-select? I have got validations to work on inputs on submit but for select it works only if you have touched it once atleast and then click submit.
@abqadeer, can you give an example of how you got the validations on submit to work?
I could not figure out how to set touched on elements on submit for it to work correctly.
however i did the following for the error message colors:
+input did not mark errors in red
+select does not have a container, so not md-hint. So i created one that mocked it.
I just realized they they added md-error ... and the need for some of my css is no longer needed. However I still dont know how to make the input trigger in error when you have not touched it.
If this can help someone, md-error works fine with formControl, for example:
[HTML]
<fieldset[disabled]="isSubmitting"><md-input-containerclass="full-width"><md-error>{{tagField.errors ? tagField.errors.missedTag : null}}</md-error><inputmdInputclass="article-tags" type="text" placeholder="Enter tags"
[formControl]="tagField" (keyup.enter)="addTag()"/><md-chip-list><md-chip*ngFor="let tag of article.tags"><md-icon(click)="removeTag(tag)">delete</md-icon><span>{{tag}}</span></md-chip></md-chip-list><md-hint>Press [enter] to add the tag</md-hint></md-input-container></fieldset><fieldset[disabled]="isSubmitting"><buttonmd-raised-buttontype="button" (click)="submitForm()" [disabled]="checkValidForm()"><md-icon>publish</md-icon><span>Submit</span></button></fieldset>
[TS]
this.fb.group({tagField: []});checkValidForm(): boolean {if(this.article.tags.length<1){this.tagField.setErrors({'missedTag': 'Please add at last one tag'});}return!this.articleForm.valid||this.article.tags.length<1;}
The docs seems to be broken here as well. Was looking forward to experimenting with this feature, but will have to wait a while until everything is back to normal.
Activity
[-]input validation system (ngControl support) (CSS)[/-][+]Add guidance for styling invalid inputs[/+]cschroeter commentedon May 18, 2016
The @HostBinding or better the setAttribute() function is not case-sensitive. This results in
and unfortunately this don't work.
Any ideas?
leocaseiro commentedon Oct 7, 2016
For the time being, I'm using a
md-hintto show my error messages:It might help someone
csabattilas commentedon Oct 13, 2016
Is there a class we can use linked to theming?
leocaseiro commentedon Oct 13, 2016
@krigton You can use the SASS
md-colorfor theming,see more on the guide
csabattilas commentedon Oct 13, 2016
so no class already there for errors? we can put what we want?
leocaseiro commentedon Oct 24, 2016
Hi @krigton, yep. My solution is temporary.
Hope works for you.
You can use any color from material or create your own.
Example:
csabattilas commentedon Nov 1, 2016
@leocaseiro thanks
9 remaining items
abqadeer commentedon Apr 25, 2017
How to divider color for md-select? I have got validations to work on inputs on submit but for select it works only if you have touched it once atleast and then click submit.
tmburnell commentedon May 2, 2017
@abqadeer, can you give an example of how you got the validations on submit to work?
I could not figure out how to set touched on elements on submit for it to work correctly.
however i did the following for the error message colors:
+input did not mark errors in red
+select does not have a container, so not md-hint. So i created one that mocked it.
tmburnell commentedon May 2, 2017
I just realized they they added md-error ... and the need for some of my css is no longer needed. However I still dont know how to make the input trigger in error when you have not touched it.
coder925 commentedon May 3, 2017
@tmburnell , there is a workaround described in #4232 for allowing the md-error to show an error even if the control is not touched.
CDDelta commentedon May 3, 2017
@tmburnell running .valid on the input form will also show the md-error on all invalid inputs. (*for reactive forms)
onalbi commentedon May 3, 2017
If this can help someone, md-error works fine with formControl, for example:
[HTML]
[TS]
mmalerba commentedon May 5, 2017
Closing this since we now have
<md-error>and a section in the input documentation on how to use itdavorzdralo commentedon Jun 30, 2017
@mmalerba - we do? The documentation on https://material.angular.io/components/input/overview is broken, I can't see example code and Plunkers don't do anything, and docs don't even try to explain how to have multiple messages.
steve-todorov commentedon Jul 3, 2017
The docs seems to be broken here as well. Was looking forward to experimenting with this feature, but will have to wait a while until everything is back to normal.
atbe commentedon Jul 3, 2017
@davorzdralo Confirmed still broken on my end.
willshowell commentedon Jul 3, 2017
@davorzdralo @steve-todorov @atbe
Dunno why that particular example is broken (cc @amcdnl), but the source is here:
https://github.com/angular/material2/tree/master/src/material-examples/input-errors
and here's the example in a plunker:
https://plnkr.co/edit/mS8vyDKHLUhC9YOr84Aw?p=preview
chore: bump versions in package.json file for new release (angular#348)
angular-automatic-lock-bot commentedon Sep 6, 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.