-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
47 lines (41 loc) · 1.26 KB
/
Copy pathindex.html
File metadata and controls
47 lines (41 loc) · 1.26 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Join Chat Room</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Welcome to Real-Time Chat</h1>
<div class="join-box">
<h2>Join a Room</h2>
<input type="text" id="username" placeholder="Enter your username" required>
<select id="room">
<option value="Choose">Choose a Room</option>
<option value="General">General</option>
<option value="Tech">Tech</option>
</select>
<button onclick="joinChat()">Join Chat</button>
</div>
</div>
<script>
function joinChat() {
const username = document.getElementById("username").value.trim();
const room = document.getElementById("room").value;
if (!username) {
alert("Please enter a username!");
return;
}
if (room === "Choose") {
alert("Please select a valid room!");
return;
}
localStorage.setItem("username", username);
localStorage.setItem("room", room);
window.location.href = "chat.html";
}
</script>
</body>
</html>