forked from ANSHIKA-26/WordWise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.html
188 lines (171 loc) · 5.88 KB
/
signup.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WordWise</title>
<link rel="shortcut icon" type="image/x-icon" href="/images/favi.webp" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="signup.css" />
<style>
.input-field {
position: relative;
margin-bottom: 20px;
}
.input-box {
width: 100%;
padding-right: 40px; /* Extra space for the eye icon */
padding-left: 10px;
height: 40px;
box-sizing: border-box; /* Ensure padding is included in width */
}
.toggle-eye {
cursor: pointer;
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%); /* Align vertically in the center */
color: black;
font-size: 18px;
margin-top: 15px;
}
.error {
color: red;
font-size: 12px;
margin-top: 5px;
}
</style>
</head>
<body>
<header class="navbar">
<div class="logo">
<h2><a class="home-link" href="index.html">WordWise</a></h2>
</div>
</header>
<main>
<div class="container-signup">
<div class="box-login">
<div class="top-header">
<h2>Sign Up</h2>
</div>
<div class="input-group">
<div class="input-field">
<label for="Name">Name</label><br />
<input type="text" id="name" class="input-box" aria-label="name" placeholder="Enter Name" />
</div>
<div class="input-field">
<label for="Mail">Email</label><br />
<input type="text" id="email" class="input-box" placeholder="Enter Email" />
</div>
<!-- Password Field with Toggle Eye Icon inside -->
<div class="input-field">
<label for="password">Password</label><br />
<input
type="password"
id="password"
class="input-box"
placeholder="Enter Password"
aria-label="password"
oninput="validatePassword()"
/>
<span
class="toggle-eye"
onclick="togglePassword('password', 'eye-icon1')"
>
<i id="eye-icon1" class="fa fa-eye-slash"></i>
</span>
<div class="error" id="passwordError"></div>
</div>
<!-- Confirm Password Field with Toggle Eye Icon inside -->
<div class="input-field">
<label for="confirm-password">Confirm Password</label><br />
<input
type="password"
id="confirm-password"
class="input-box"
aria-label="confirm password"
placeholder="Confirm Password"
/>
<span
class="toggle-eye"
onclick="togglePassword('confirm-password', 'eye-icon2')"
>
<i id="eye-icon2" class="fa fa-eye-slash"></i>
</span>
</div>
<div class="submit">
<input
type="submit"
class="Input-submit"
value="SIGN UP"
aria-label="submit"
onclick="submitForm(event)"
/>
</div>
</div>
<div class="new">
<span>Already have an account?</span>
<a href="login.html">Log In</a>
</div>
</div>
</div>
</main>
<!-- Font Awesome for icons -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
<script>
// Toggle password visibility for both password fields
function togglePassword(inputId, iconId) {
const passwordField = document.getElementById(inputId);
const eyeIcon = document.getElementById(iconId);
if (passwordField.type === "password") {
passwordField.type = "text";
eyeIcon.classList.remove("fa-eye-slash");
eyeIcon.classList.add("fa-eye");
} else {
passwordField.type = "password";
eyeIcon.classList.remove("fa-eye");
eyeIcon.classList.add("fa-eye-slash");
}
}
// Password validation
function validatePassword() {
const password = document.getElementById("password").value;
const errorElement = document.getElementById("passwordError");
const hasUpperCase = /[A-Z]/.test(password);
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
const isValidLength = password.length >= 8;
if (!hasUpperCase || !hasSpecialChar || !isValidLength) {
errorElement.textContent =
"Password must have at least 1 uppercase letter, 1 special character, and be at least 8 characters long.";
return false;
} else {
errorElement.textContent = ""; // Clear error
return true;
}
}
// Handle form submission
async function submitForm(event) {
event.preventDefault()
if (!validatePassword()) {
event.preventDefault(); // Prevent form submission if validation fails
}
const password = document.getElementById("password").value;
const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
const data = {
name: name,
email: email,
password: password
};
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
};
await fetch("http://localhost:3000/signup", options)
}
</script>
</body>
</html>