-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistration_Form.html
57 lines (50 loc) · 2.02 KB
/
Registration_Form.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">
<title>Login Form</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f4f4f4; }
form { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; }
button { width: 100%; padding: 10px; background-color: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer; }
.error { color: red; font-size: 0.9em; }
.success { color: green; font-size: 1.1em; }
</style>
</head>
<body>
<form id="loginForm">
<input type="text" id="username" placeholder="Username" required>
<input type="email" id="email" placeholder="Email" required>
<input type="password" id="password" placeholder="Password (min 6 chars)" required>
<button type="submit">Submit</button>
<p id="feedback" class="error"></p>
</form>
<script>
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
let feedback = document.getElementById('feedback');
feedback.textContent = '';
let username = document.getElementById('username').value.trim();
let email = document.getElementById('email').value.trim();
let password = document.getElementById('password').value;
if (!username || !email || !password) {
feedback.textContent = 'All fields are required.';
return;
}
let emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if (!emailPattern.test(email)) {
feedback.textContent = 'Please enter a valid email.';
return;
}
if (password.length < 6) {
feedback.textContent = 'Password must be at least 6 characters.';
return;
}
feedback.textContent = 'Success! Form submitted.';
feedback.className = 'success';
});
</script>
</body>
</html>