0

I have built out an example of what I'm trying to accomplish. I want to be able to make an array of passwords where if one is correct, then they are all sent to another page. However, in the following example it is not working. If I input the name that is suppose to pop up with a hello message it states its wrong when I have it in an Array.

let textarea = document.getElementById('banner');
let okbutton = document.getElementById('btn');
let form = document.getElementById('user-form');
let textBox = document.getElementById('text-box');
let spanMe = document.getElementById('spans');
let userNameIs = ['marquise', 'quise', 'tom'];

textarea.style.display = 'none';
spanMe.style.display = 'none';
textarea.style.display = 'none';

okbutton.addEventListener('click', function() {
    if (textBox.value.length <= 4) {
        spanMe.style.display = 'block';
        spanMe.style.color = 'red';   
    } else if (textBox == userNameIs[1]) {
        spanMe.style.display = 'none';
        textarea.style.display = "block"
        textarea.innerText = 'hello' + ' ' + textBox.value;
    } else if (textBox != userNameIs[1])
        spanMe.style.display = 'block';
    spanMe.style.color = 'red';
});

0 Answers0