Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove asterisk from required field in Angular Material and add (optional) beside label for optional labels

Tags:

People also ask

How do I hide an asterisk?

Removing the Required AsteriskGo to Style > Text > Text Options and uncheck the option Show Required Asterisks.

Are asterisk required?

Asterisk (*) next to a form control's label usually indicates it as "required". Oftentimes, this asterisk's purpose is then explained somewhere else on the page. Many users (especially screen reader users) may be confused with that, so be sure to make this information is easily accessible.


I am using angular 2 material design for form fields. So with that every required fields appear with asterisk which i don't want.Also, for non-required fields, i want an optional text to be appear in brackets next to the label.

I am using something like below to achieve it but that's not working.

My code-

<md-input required md-no-asterisk id="" placeholder="First Name" [(ngModel)]="" ngControl="txtFirstName" #firstName="ngModel"></md-input>

When I am removing md-input starting and end tag and just using input tag then the asterisk goes away but some default text called appears as a value of the field.

I want to use required and optional fields as a label.

Any help would be much appreciated.