Untitled

mail@pastecode.io avatar
unknown
plain_text
10 months ago
686 B
5
Indexable
Never
<!DOCTYPE html>
<html>
<head>
  <title>Character Limit Text Box</title>
  <script>
    function limitCharacters() {
      var textbox = document.getElementById("message");
      var charCount = document.getElementById("charCount");
      charCount.textContent = textbox.value.length;
      
      if (textbox.value.length > 3000) {
        textbox.value = textbox.value.substr(0, 3000);
        charCount.style.color = "red";
      } else {
        charCount.style.color = "black";
      }
    }
  </script>
</head>
<body>
  <textarea id="message" rows="10" cols="40" oninput="limitCharacters()"></textarea>
  <p>Character Count: <span id="charCount">0</span> / 3000</p>
</body>
</html>