-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical_13_reg.html
More file actions
65 lines (57 loc) · 2.4 KB
/
Practical_13_reg.html
File metadata and controls
65 lines (57 loc) · 2.4 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Register | HAC Services</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./Reg_Log.css">
</head>
<body class="register_page">
<div class="form-container">
<h2>Register</h2>
<form action="./Practical_13_Reg.php" method="post" onsubmit="return validateRegister()">
<input type="text" name="name" id="reg-name" placeholder="Name" required>
<input type="email" name="email" id="reg-email" placeholder="Email" required>
<select name="role" id="reg-role" required>
<option value="">Register as...</option>
<option value="admin">Admin</option>
<option value="broker">Broker</option>
<option value="buyer">Buyer</option>
</select>
<input type="password" name="password" id="reg-password" placeholder="Password" required>
<input type="password" name="confirm" id="reg-confirm" placeholder="Confirm Password" required>
<input type="submit" value="Register">
</form>
</div>
<script>
function validateRegister() {
const name = document.getElementById("reg-name").value;
const email = document.getElementById("reg-email").value;
const role = document.getElementById("reg-role").value;
const pass = document.getElementById("reg-password").value;
const confirm = document.getElementById("reg-confirm").value;
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (name.length < 3) {
alert("Name must be at least 3 characters");
return false;
}
if (!emailPattern.test(email)) {
alert("Invalid email format");
return false;
}
if (role === "") {
alert("Please select a role (Admin or Broker or Buyer)");
return false;
}
if (pass.length < 6) {
alert("Password must be at least 6 characters");
return false;
}
if (pass !== confirm) {
alert("Passwords do not match");
return false;
}
return true;
}
</script>
</body>
</html>