-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (24 loc) · 874 Bytes
/
script.js
File metadata and controls
29 lines (24 loc) · 874 Bytes
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
let container = document.getElementById("container");
let registerBtn = document.getElementById("register");
let loginBtn = document.getElementById("login");
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const buttons = [registerBtn, loginBtn];
buttons.forEach(button => {
button.onclick = function () {
const action = this.id === "register" ? "add" : "remove";
container.classList[action]("active");
};
});
document.getElementById('signup-button').addEventListener('click', function(event) {
const emailInput = document.getElementById('i1').value;
if (emailRegex.test(emailInput)) {
const form = this.closest('form');
if (form && form.name === 'f1') {
event.preventDefault();
window.location.href = 'navbar.html';
}
} else {
alert('Invalid email address');
event.preventDefault();
}
});