Django-Learn/djlearn/pages/static/js/login.js

24 lines
665 B
JavaScript

document.addEventListener('DOMContentLoaded', (event) => {
const rmCheck = document.getElementById("remember_me"),
emailInput = document.getElementById("id_username");
if (localStorage.checkbox && localStorage.checkbox !== "") {
rmCheck.setAttribute("checked", "checked");
emailInput.value = localStorage.username;
} else {
rmCheck.removeAttribute("checked");
emailInput.value = "";
}
})
function lsRememberMe() {
if (rmCheck.checked && emailInput.value !== "") {
localStorage.username = emailInput.value;
localStorage.checkbox = rmCheck.value;
} else {
localStorage.username = "";
localStorage.checkbox = "";
}
}