-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
57 lines (57 loc) · 2.18 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
<!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="style.css">
<title>Sign Up - LearnHub</title>
</head>
<body>
<div class="form-container">
<h1>Sign Up</h1>
<div id="error-message" class="error-message"></div>
<form onsubmit="return validateForm()">
<div class="form-group">
<input type="text" name="myname" id="name" placeholder="Full Name" required>
</div>
<div class="form-group">
<input type="email" name="myemail" id="email" placeholder="Email" required>
</div>
<div class="form-group">
<input type="password" name="mypassword" id="password" placeholder="Password" required>
</div>
<button type="submit" class="up">Sign Up</button>
</form>
<p>Already have an account? <a href="login.html">Login</a></p>
<div class="divider">
<span>or</span>
</div>
<a href="https:\\google.com"><button class="goo">Sign up with Google</button></a>
</div>
<script>
function validateForm() {
const email=document.getElementById("email").value.trim();
const password=document.getElementById("password").value.trim();
const errorMessage=document.getElementById('error-message');
errorMessage.style.display="none";
errorMessage.textContent='';
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if(!emailPattern.test(email))
{
errorMessage.textContent="Please enter a valid email address.";
errorMessage.style.display="block";
return false;
}
if(password.length<8)
{
errorMessage.style.display='block';
errorMessage.textContent="Password must be at least 8 characters long.";
return false;
}
alert("Registration successful!");
window.location.href="login.html";
return false;
}
</script>
</body>
</html>