const phone = document.querySelector('#phone')
const password = document.querySelector('#password')
const confirmPassword = document.querySelector('#confirm-password')
const errorMessage = document.querySelector('.errorMessage')
const input = [email, phone, password, confirmPassword]
input.forEach((item) => {
item.addEventListener("focusin", () => {
errorMessage.textContent = "";
item.classList.remove("error");
if (item == password || item == confirmPassword) {
password.classList.remove("error");
confirmPassword.classList.remove("error");
}
});
});```
I'm trying to create a validation form in JS but i can't figure out why "item" for the eventlistener has a typeerror of null.
#why is my element(item) a null?
5 messages · Page 1 of 1 (latest)
You have a const input then call item
You just literally haven't assigned anything to item, try input instesd
Oh wait I read it wrong
Console log input and see what it says