JSFiddle - React, Tailwind, and code Playground

HTML

<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
<label for="fName">First Name<sup>*</sup></label>
      
<input type="text" autocomplete="off" name="fName" id="fName" value='' required/>

JavaScript

function getLabelFromInputID(inputID){
    var prevSib = document.getElementById(inputID).previousSibling;
    //remove the spaces if any exists
    while(prevSib.nodeName=='#text') prevSib=prevSib.previousSibling;
    if(prevSib.getAttribute('for') != inputID) prevSib = null;
    return prevSib;
}
onclick = function(){
   var label = getLabelFromInputID('fName');  
   if(label != null)  label.style.color='red';
};