36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
const main = document.querySelector("#main");
|
|
const resultMail = document.querySelector("#result_mail");
|
|
const passwordTest = document.querySelector("#password_test");
|
|
const resultPassword = document.querySelector("#result_password");
|
|
const passwordManage = document.querySelector("#password_manage");
|
|
const security2AF = document.querySelector("#security_2AF");
|
|
const cookie = document.querySelector("#cookie");
|
|
|
|
|
|
mailRegex = new RegExp("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])");
|
|
|
|
|
|
document.querySelectorAll("input").forEach((el) => {
|
|
el.addEventListener("change", (e => {
|
|
el.classList.remove("error");
|
|
}));
|
|
});
|
|
|
|
main.querySelector("input").addEventListener("keyup", (e) => {
|
|
if (e.key === "Enter") {
|
|
mailValid();
|
|
}
|
|
});
|
|
|
|
|
|
function mailValid() {
|
|
let input = main.querySelector("input");
|
|
if (mailRegex.test(input.value)) {
|
|
resultMail.classList.remove("hide");
|
|
resultMail.scrollIntoView({
|
|
"behavior": "smooth"
|
|
});
|
|
} else {
|
|
input.classList.add("error");
|
|
}
|
|
}
|