1
1
const header = document . querySelector ( 'header' ) ;
2
2
const getForms = document . querySelectorAll ( 'form' ) ;
3
- const textErrors = document . querySelectorAll ( '.erro-text' ) ;
4
- const btns = document . querySelectorAll ( 'button' ) ;
3
+
5
4
6
5
window . addEventListener ( 'scroll' , function ( ) {
7
6
if ( window . scrollY > 0 ) {
8
- header . style . backgroundColor = "$header-bg " ;
7
+ header . style . backgroundColor = "/* Your color or variable here */ " ;
9
8
header . style . backdropFilter = "blur(50px)" ;
10
9
header . style . boxShadow = "0 4px 6px rgba(0, 0, 0, 0.1)" ;
11
10
header . style . transition = "all 0.5s ease" ;
@@ -17,35 +16,48 @@ window.addEventListener('scroll', function () {
17
16
}
18
17
} ) ;
19
18
20
- getForms . forEach ( ( form ) => {
19
+ getForms . forEach ( ( form , index ) => {
21
20
const inputTag = form . querySelector ( 'input[type="email"]' ) ;
22
21
const textBox = form . querySelector ( 'input' ) ;
23
22
const textError = form . querySelector ( '.erro-text' ) ;
23
+ const btns = form . querySelector ( 'button' ) ;
24
+
24
25
25
26
form . addEventListener ( 'submit' , function ( event ) {
26
27
if ( inputTag . value === '' ) {
27
28
textError . textContent = "Please provide a valid email" ;
28
29
textError . style . textAlign = "left" ;
29
- textError . style . color = "#E4859F" ;
30
30
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
+
31
38
event . preventDefault ( ) ;
32
39
} else if ( inputTag . value !== '' ) {
33
- textError . textContent = "Plase check your email" ;
40
+ textError . textContent = "Please check your email" ;
34
41
textError . style . textAlign = "left" ;
35
42
textError . style . color = "pink" ;
36
43
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
+ } ) ;
37
56
} else {
38
57
textError . style . color = "transparent" ;
58
+ textBox . textContent = "" ;
59
+
39
60
}
40
61
} ) ;
41
62
} ) ;
42
-
43
- btns . forEach ( ( btn ) => {
44
- btn . addEventListener ( 'click' , function ( event ) {
45
- ;
46
-
47
-
48
- } ) ;
49
- } ) ;
50
-
51
-
63
+
0 commit comments