-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup_script.js
60 lines (49 loc) · 1.67 KB
/
signup_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function togglePassword() {
var passwordField = document.getElementById("confirmPassword");
if (passwordField.type === "password") {
passwordField.type = "text";
} else {
passwordField.type = "password";
}
}
function login() {
var loginBtn = document.querySelector(".login-btn");
loginBtn.disabled = true;
// loader element
var loader = document.createElement("div");
loader.className = "loader";
document.body.appendChild(loader);
// delay
setTimeout(function() {
// Remove the loader
document.body.removeChild(loader);
// Enable login button
loginBtn.disabled = false;
// login logic here
const email = document.getElementById('email');
const password = document.getElementById('password');
const confirmPassword= document.getElementById('confirmPassword');
// Validate email
if (!validateEmail(email.value)) {
alert('Please enter a valid email address.');
return;
}
// Validate password
if (!validatePassword(password.value)) {
alert('Please enter a valid password.');
return;
}
if (password.value != confirmPassword.value) {
alert('Password not matched\nPlease enter same password');
return;
}
alert("SignUp Successful");
window.location.href = 'index.html';
}, 1000); // delay of 1 second
}
function validateEmail(email) {
return /\S+@\S+\.\S+/.test(email);
}
function validatePassword(password) {
return password.length >= 8;
}