CeBIT Hannover

Digitalisierung im Klassenzimmer

19.10.2020 (vor 2 Monaten aktualisiert)

CeBIT Hannover

But what would happen if you forget to add the asterisk after a form field or if the form is dynamically created, here is a quick tip for automatically adding a red asterisk next to required fields just by using CSS. Here is a standard HTML for creating a form field as you can see the label has a required class therefore we need to add an asterisk after this label.

If you would prefer to have the asterisk after the textbox then instead of searching for labels with a class of required you can search for input boxes with an attribute of required.

A red asterix is a common approach in website UX to show that a form field is required to be filled out by the using before submitting the form. Therefore when creating the form you will have to remember to add this in the HTML where you want the asterisk to appear which is commonly after the label of the form field.

Noch keine Kommentare vorhanden.