-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (46 loc) · 1.45 KB
/
index.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const bar = document.getElementById('bar');
const nav = document.getElementById('navbar');
const close = document.getElementById('close');
if(bar){
//this var 'bar' will store value as true if it is clicked that is if bar
//is clicked we want to do the functions
//we want to add and eventlistner when a click func is performed the arrow func will execute
//ie.our we add a class "active" to our navbar which will display that section
bar.addEventListener('click',() => {
nav.classList.add('active');
})
}
if(close){
close.addEventListener('click', () => {
nav.classList.add('close_btn')
//////////OR/////////////
nav.classList.remove('active')
})
}
//EMAIL JS JS CODE
function validate(){
let email = document.querySelector('.email');
let sendBtn = document.querySelector('.normal1');
sendBtn.addEventListener("click", (e)=>{
e.preventDefault();
if(email.value == "" || email.value != "@"){
emptyerror();
}
else{
sendmail(email.value);
success();
}
});
}
validate();
function sendmail(email){
emailjs.send("service_jxfymrd","template_zw7phns",{
to_name: email,
});
}
function emptyerror(){
swal("Oh No.....", "Email field cannot be empty!", "error");
}
function success(){
swal("Good job!", "Email sent successfully", "success");
}