Skip to content

Commit 83e37aa

Browse files
authored
Merge pull request #22 from jen67/newapp
added more functions
2 parents 261d984 + f72741d commit 83e37aa

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

fylo-landing-page/main.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const header = document.querySelector('header');
22
const getForms = document.querySelectorAll('form');
3-
const textErrors = document.querySelectorAll('.erro-text');
4-
const btns = document.querySelectorAll('button');
3+
54

65
window.addEventListener('scroll', function () {
76
if (window.scrollY > 0) {
8-
header.style.backgroundColor = "$header-bg";
7+
header.style.backgroundColor = "/* Your color or variable here */";
98
header.style.backdropFilter = "blur(50px)";
109
header.style.boxShadow = "0 4px 6px rgba(0, 0, 0, 0.1)";
1110
header.style.transition = "all 0.5s ease";
@@ -17,35 +16,48 @@ window.addEventListener('scroll', function () {
1716
}
1817
});
1918

20-
getForms.forEach((form) => {
19+
getForms.forEach((form, index) => {
2120
const inputTag = form.querySelector('input[type="email"]');
2221
const textBox = form.querySelector('input');
2322
const textError = form.querySelector('.erro-text');
23+
const btns = form.querySelector('button');
24+
2425

2526
form.addEventListener('submit', function (event) {
2627
if (inputTag.value === '') {
2728
textError.textContent = "Please provide a valid email";
2829
textError.style.textAlign = "left";
29-
textError.style.color = "#E4859F";
3030
textBox.style.border = "2px solid #E4859F";
31+
32+
if (index === 1) {
33+
textError.style.color = "white";
34+
} else {
35+
textError.style.color = "#E4859F";
36+
}
37+
3138
event.preventDefault();
3239
} else if (inputTag.value !== '') {
33-
textError.textContent = "Plase check your email";
40+
textError.textContent = "Please check your email";
3441
textError.style.textAlign = "left";
3542
textError.style.color = "pink";
3643
textBox.style.border = "2px solid pink";
44+
45+
if (index === 1) {
46+
textError.style.color = "white";
47+
} else {
48+
textError.style.color = "#E4859F";
49+
}
50+
51+
event.preventDefault();
52+
btns.addEventListener('click', function () {
53+
textError.style.color = "transparent";
54+
textBox.value = "";
55+
});
3756
} else {
3857
textError.style.color = "transparent";
58+
textBox.textContent = "";
59+
3960
}
4061
});
4162
});
42-
43-
btns.forEach((btn) => {
44-
btn.addEventListener('click', function (event) {
45-
;
46-
47-
48-
});
49-
});
50-
51-
63+

0 commit comments

Comments
 (0)