jQuery(document).ready(function($) {
$('.hp-form__field input[required]').each(function() {
// Find the label associated with the required input
var label = $(this).closest('.hp-form__field').find('.hp-field__label span');
// Check if the star is already added to avoid duplicates
if (!label.text().includes('*')) {
//add css class : .req{color:red;font-weight:bold;font-size:1.2em}
label.append(' <span class="req">*</span>');
}
});
});
CSS :
/*remove (optional)*/
.hp-field__label small {font-size: 0;}
.hp-field__label small:after {content:''; font-size: small;}
/*style for required field asterisk*/
.req{
color:red;font-weight:bold;font-size:1.2em;
}
I don’t know if you are using a code snippet plugin, as suggested by Hivepress team.
I am using WPCode, and it allows you to add/edit both php and js code.