Skip to content

Commit 781ac9e

Browse files
author
kohanman
committed
added files needed for the prep work and completed the prep
1 parent 8f3d6cf commit 781ac9e

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

Sprint-3/prep/index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Document</title>
7+
<script defer src="script.js"></script>
8+
</head>
9+
<body>
10+
<section>
11+
<h3>Character limit</h3>
12+
<label for="comment-input"
13+
>Please enter your comment in the text area below
14+
</label>
15+
<textarea
16+
id="comment-input"
17+
name="comment-input"
18+
rows="5"
19+
maxlength="200"
20+
></textarea>
21+
<p id="character-limit-info"></p>
22+
</section>
23+
</body>
24+
</html>

Sprint-3/prep/script alt.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const textarea = document.querySelector("textarea");
2+
const remainingCharacters = textarea.maxLength - textarea.value.length;
3+
console.log(textarea.maxLength);
4+
5+
const charactersLeftP = document.querySelector("#character-limit-info");
6+
charactersLeftP.innerText = `You have ${remainingCharacters} characters remaining`;
7+
8+
9+
10+
textarea.addEventListener("keyup",
11+
() => const remainingCharacters = textarea.maxLength - textarea.value.length;
12+
const charactersLeftP = document.querySelector("#character-limit-info");
13+
charactersLeftP.innerText = `You have ${remainingCharacters} characters remaining`;
14+
console.log(remainingCharacters);
15+
);

Sprint-3/prep/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const textarea = document.querySelector("textarea");
2+
3+
updateCharacterLimit();
4+
5+
function updateCharacterLimit() {
6+
const remainingCharacters = textarea.maxLength - textarea.value.length;
7+
const charactersLeftP = document.querySelector("#character-limit-info");
8+
charactersLeftP.innerText = `You have ${remainingCharacters} characters remaining`;
9+
console.log(remainingCharacters);
10+
}
11+
12+
textarea.addEventListener("keyup", updateCharacterLimit);

0 commit comments

Comments
 (0)