-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (33 loc) · 1.03 KB
/
Copy pathscript.js
File metadata and controls
40 lines (33 loc) · 1.03 KB
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
34
35
36
37
38
39
40
const submit = document.getElementById('submit');
const val = document.querySelector('input');
const error = document.getElementById('error');
const invalid = document.getElementById('invalid');
const pop = document.getElementById('pop');
const imgDesktop = document.getElementById('img-desktop');
const imgMobile = document.getElementById('img-mobile');
error.hidden = true;
invalid.hidden = true;
const subscribe = (event) => {
const value = val.value;
event.preventDefault();
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value) && value.length){
error.hidden = true;
invalid.hidden = true;
pop.hidden = false;
setTimeout(() => {
pop.hidden = true;
}, 1000);
} else {
error.hidden = false;
invalid.hidden = false;
}
}
const widthScreen = (data) => {
if(data < 700) {
imgDesktop.hidden = true;
} else {
imgMobile.hidden = true;
}
}
widthScreen(screen.width)
submit.addEventListener('click', subscribe);