Ok its clear to me. Have to put all the code in one place, not in two script tags. The second is these strings with ERROR and text in text fiels has to be a params who is send by another function to current function.
document.getElementById("header_error").innerHTML = paramError;
document.getElementById("text_msg").innerHTML = paramText;
Somethink like this.
And the last think is to use queryselector method by class not by ID.