var credentials = { login: 'admin', password: 'qwerty',}; var userLogin; var userPassword; function func(){ userLogin = document.getElementById("login").value; userPassword = document.getElementById("password").value; if (userLogin === credentials.login && userPassword === credentials.password){ document.getElementById("success").style.display="block"; return false; } else { document.getElementById("wrong").style.display="block"; return false; } } document.getElementById("submit").onclick = func;