Mark a required label with an asterisk

Mark a required label with an asterisk

If you set the [Required] annotation on a required model property, the input field gets a data-val-required attribute in the view.

With this jQuery snippet an asterisk (“*”) gets appended to the corresponding label:

Thomas Bandixen's Picture

About Thomas Bandixen

Thomas Bandixen is a senior consultant, Microsoft Certified Trainer (MCT) and speaker working for the swiss IT service provider Trivadis AG. His primary focus is on modern web architectures using Angular, TypeScript, HTML5, CSS and ASP.NET Core.

Switzerland https://thomasbandixen.ch