title: Apply JavaScript Email Error Box to other elements
body: <p>I have built a login system with LocalStorage on my website and would like to build an error message if I enter it incorrectly. Since I have already got help for the email error on another page, I would like to add the message that appears there to my other error messages. Is there a solution to apply the Email Error message to other elements or do I have to style and rebuild all messages? If there is a possibility I would like it (below in the code) for the functions "checkRegisterEnter" and "checkRegisterPassword" for the alert replacement. The email check can be seen below.</p>
  
  <p>Javascript code:</p>
  
  <pre><code>function checkRegisterEnter(){}
    if(givenname.value == 0){
      alert("Name field is Empty!")
    }
  
  function checkRegisterPassword(){
    if(password.value !== password2.value) {
      alert('The first password does not match the second!')
    }
  }
  
  //Email_Check
  const checkrform = document.getElementById("register.form")[0];
  const checkremail = document.getElementById("ri3");
  let remailerror = checkremail;
  while ((remailerror = remailerror.nextSilbing).nodeType != 1);
  const remailRegExp = /^[a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
  
  function addEvent(remailelement,remailevent,callback){
    let previousEventCallBack = remailelement["on"+remailevent];
    remailelement["on"+remailevent] = function (e) {const remailoutput = callback(e);
  
    }
  };
  </code></pre>
  
  <p>(Translated with Google Translate, errors may be included.)</p>
  
  <p>Edit: Problem has still not been solved. Would be helpful if someone knew the answer.</p>