Skip to content

Instantly share code, notes, and snippets.

@evandonovan
Last active April 11, 2024 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evandonovan/23b00476e3146e5fe8f3d4285acfdc08 to your computer and use it in GitHub Desktop.
Save evandonovan/23b00476e3146e5fe8f3d4285acfdc08 to your computer and use it in GitHub Desktop.
Character Counting Form
function countCharacters() {
var input = document.getElementById('inputText').value;
var count = input.length;
document.getElementById('charCount').innerHTML = count + " characters";
}
<!DOCTYPE html>
<html>
<head>
<title>Character Counting Form</title>
<script src="charcount.js"></script>
</head>
<body>
<form>
<label for="inputText">Text:</label><br>
<textarea id="inputText" onkeyup="countCharacters()" rows="4" cols="50"></textarea><br>
<label id="charCount">0 characters</label>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment