forked from akshitagupta15june/Moksh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
41 lines (34 loc) · 1.13 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
34
35
36
37
38
39
40
41
let dropMenuLinks = document.querySelector('.dropMenuLinks');
let indexOpenDropDown = document.querySelector('.indexOpenDropDown');
let closeDropDown = document.querySelector('.closeDropDown');
indexOpenDropDown.onclick = () => {
dropMenuLinks.style.right = 0;
}
closeDropDown.onclick = () => {
dropMenuLinks.style.right = '-2000px';
}
function subscribe() {
var email = document.getElementById('email').value;
// Validate email address
if (!validateEmail(email)) {
showPopup('Please enter a valid email address.');
return;
}
// send the email address to the admin
// For demonstration, let's just show a confirmation message
showPopup('You have successfully subscribed with email: ' + email);
}
function validateEmail(email) {
// Basic email validation
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
function showPopup(message) {
var popup = document.getElementById('popup');
var popuptext = document.getElementById('popuptext');
popuptext.textContent = message;
popup.classList.add('show');
setTimeout(function() {
popup.classList.remove('show');
}, 3000); // Hide popup after 3 seconds
}