.net MVC red asterisk after Required Field via jQuery

Published on Saturday, 11 August 2018

I quite liked this piece of jQuery to put a red star after any fields which were required. (Remove the space before the word SPAN.

//To enable Required boxes to have a red *
$('input[type=text][data-val-required],input[type=tel][data-val-required],input[type=email][data-val-required],input[type=number][data-val-required],input[type=date][data-val-required],input[type=password][data-val-required]').closest(".form-group").find("label").append('< span style="color:red; font-size: 1em; vertical-align: middle;"> *');