function clear_error(id){
(document.getElementById(id) != undefined) ? (document.getElementById(id).innerHTML = "") : console.log('span is not created yet');
}
I have to check that a span element has been created/defined for my error or not, if it is created then remove the inner text for the new error if not then do nothing, as i have made an error function of it in the specified class.