-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
86 lines (74 loc) · 3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="signup.css">
<title>Sign Up</title>
</head>
<body>
<form id="signupForm" action="index.html" onsubmit="return validateForm()">
<div class="container">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="email"><b>Email</b></label>
<input type="email" id="email" placeholder="Enter Email" name="email" required>
<label for="psw"><b>Password</b></label>
<input type="password" id="password" placeholder="Enter Password" name="psw" required>
<label for="psw-repeat"><b>Confirm Password</b></label>
<input type="password" id="confirmPassword" placeholder="Confirm Password" name="psw-repeat" required>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
<p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
<p>Already a member? <a href="login.html">Login</a></p>
<div class="clearfix">
<button type="submit" class="signupbtn">Sign Up</button>
</div>
</div>
</form>
<script>
function validateForm() {
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
var confirmPassword = document.getElementById("confirmPassword").value;
var passwordError = document.getElementById("passwordError");
var emailError = document.getElementById("emailError");
var passwordLengthError = document.getElementById("passwordLengthError");
// Check if passwords match
if (password !== confirmPassword) {
alert("Passwords do not match");
event.preventDefault(); // Prevent form submission
return;
}
// Check email format
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
alert("Invalid email format");
event.preventDefault(); // Prevent form submission
return;
}
// Check password length
if (password.length < 8) {
alert("Password should have atleast 8 character");
event.preventDefault();
return;
}
var symbolRegex = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
if (!symbolRegex.test(password)) {
alert("Password should have atleast 1 symbol");
event.preventDefault();
return;
}
var capitalLetterRegex = /[A-Z]/;
if(!capitalLetterRegex.test(password)) {
alert("Password should have atleast one capital letter");
event.preventDefault();
return;
}
return true; // Form submission allowed
}
</script>
</body>
</html>