const email = document.forms['form']['email'];
const password = document.forms['form']['password'];

const email_error = document.getElementById('email_error');
const password_error = document.getElementById('password_error');

const loginBtn = document.getElementById('loginBtn');
loginBtn.addEventListener('click',login)

function login(){
    let validemail = email_Verify();
    let validpassword = password_Verify();
    if (validemail && validpassword){
        window.location.href = "fooldal.html"
    }
}

function email_Verify(){
    if (email.value.indexOf("@") == -1 || email.value=='') {
        email.style.border = "1px solid red";
        email_error.style.display = "block";
        email.focus();
        password.style.border = "1px solid red";
        password_error.style.display = "block";
        password.focus();
        return false;
    }
    email_error.style.display="none";
    email.style.border = "1px solid green";
    return true;
}

function password_Verify(){
    if (password.value.length < 8) {
        password.style.border = "1px solid red";
        password_error.style.display = "block";
        password.focus();
        return false;
    }
    password_error.style.display="none";
    password.style.border = "1px solid green";
    return true;
}
