<input type="text" name="name" id="example-id" autocomplete="off">

<div>👇現在の文字数</div>
<div id="current-length"></div>
// input要素オブジェクト
const inputElem = document.getElementById("example-id");
// 値を埋め込む先
const currentLengthElem = document.getElementById("current-length");

inputElem.addEventListener('input', (event) => {
  currentLengthElem.innerText = event.target.value.length;
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.