-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
74 lines (70 loc) · 1.71 KB
/
index.html
File metadata and controls
74 lines (70 loc) · 1.71 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
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Character Counter App</title>
<style>
body {
font-family: system-ui, Arial;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background: #f3f4f6;
}
.container {
background: white;
padding: 25px 30px;
border-radius: 12px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
width: 350px;
text-align: center;
}
textarea {
width: 100%;
height: 100px;
font-size: 15px;
border-radius: 8px;
padding: 10px;
resize: none;
border: 1px solid #d1d5db;
}
p {
margin-top: 10px;
font-size: 14px;
}
.count {
font-weight: bold;
}
.red {
color: #ef4444;
}
</style>
</head>
<body>
<div class="container">
<h3>📝 Character Counter</h3>
<textarea id="textInput" placeholder="Type your message..."></textarea>
<p><span id="charCount" class="count">0</span> / <span id="maxCount">100</span></p>
</div>
<script>
const textarea = document.getElementById("textInput");
const charCount = document.getElementById("charCount");
const maxCount = document.getElementById("maxCount");
const limit = 100;
maxCount.textContent = limit;
textarea.addEventListener("input", () => {
const length = textarea.value.length;
charCount.textContent = length;
if (length > limit) {
charCount.classList.add("red");
textarea.style.borderColor = "#ef4444";
} else {
charCount.classList.remove("red");
textarea.style.borderColor = "#d1d5db";
}
});
</script>
</body>
</html>