When defining a input field as required
in angular material, it automatically adds a asterisk after the label. I've found a lot of questions asking how to add it, but none how to remove it. It seems that it wasn't default at the time they asked it, but according to this reference now it is the default behaviour (I'm using the version available on https://github.com/angular/material **).
How do I remove it and get the same behavior as shown here by @Styx.
**By the time I had this problem I thought that I was using the latest release (v. 1.0.5), but I was in fact using the master version, which could have the asterisk feature.
Removing the Required AsteriskGo to Style > Text > Text Options and uncheck the option Show Required Asterisks.
Fields marked with * are mandatory Using an asterisk (*) symbol content authors notify mandatory field. This is said to be one of the accessible modes of identifying a mandatory field, however this method also will be a problem with screen readers in certain times.
Even though it looks like this feature is not yet in 1.0.5, release notes ...
I looked through this commit, and this probably is what we are looking for:
md-no-asterisk
<input md-maxlength="30" required md-no-asterisk name="description" ng-model="project.description">
This is the closed issue for this feature, status says 'needs: merge'
When using Angular Materials mat-form-field
you can add the hideRequiredMarker
<mat-form-field hideRequiredMarker>
<input required placeholder="type here">
</mat-form-field>
Credits to @shivek-parmar How do I remove asterisk from required field in Angular Material and add (optional) beside label for optional labels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With