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.
Javascript 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.!#$%&'*+/=?^_`{|}~-]+@[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);
}
};
(Translated with Google Translate, errors may be included.)
Edit: Problem has still not been solved. Would be helpful if someone knew the answer.
Errors in JavaScript can be displayed without the use of alert boxes but using the alert box is the traditional way to do that. We can show errors with two methods without using the alert box