script.js 918 B

123456789101112131415161718192021222324252627282930313233
  1. const credentials = {
  2. login: 'admin',
  3. password: 'qwerty',
  4. };
  5. const login = document.getElementById("login");
  6. const password = document.getElementById("password");
  7. const button = document.querySelector("button");
  8. const wrapper = document.querySelector(".wrapper");
  9. const result = document.querySelector(".result");
  10. button.addEventListener("click", check);
  11. login.addEventListener("keydown", handler);
  12. password.addEventListener("keydown", handler);
  13. function check() {
  14. result.innerText = "";
  15. result.classList = [];
  16. if( credentials.login === login.value && credentials.password === password.value ){
  17. result.classList.add("done");
  18. result.innerText = "Done!";
  19. } else {
  20. result.classList.add("fail");
  21. result.innerText = "*не верный логин или пароль";
  22. }
  23. }
  24. function handler(e) {
  25. if( e.keyCode === 13 ){
  26. check()
  27. }
  28. }