-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (32 loc) · 1.3 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
let inputsContainers = document.querySelectorAll(".input-container");
document.getElementById("submit-btn").onclick = function (e) {
inputsContainers.forEach(function (elem) {
if (elem.firstElementChild.value.length > 0 && !elem.firstElementChild.validity.typeMismatch) {
elem.children[1].style.display = "none";
elem.children[2].style.display = "none";
}
else {
elem.children[1].style.display = "initial";
elem.children[2].style.display = "initial";
e.preventDefault();
}
});
}
inputsContainers.forEach(function (elem) {
elem.firstElementChild.onblur = function () {
if (elem.firstElementChild.value.length == 0 || elem.firstElementChild.validity.typeMismatch) {
{
elem.children[1].style.display = "initial";
elem.children[2].style.display = "initial";
if (elem.firstElementChild.validity.typeMismatch) {
elem.firstElementChild.style.color = "#ff7a7a";
}
}
}
}
elem.firstElementChild.onfocus = function () {
elem.children[1].style.display = "none";
elem.children[2].style.display = "none";
elem.firstElementChild.style.color = "#3e3c49";
}
});