Beginner20 min
Character counter
Keep a live character count and remaining allowance in sync.
Input eventsStrings
YOUR BUILD CHECKLIST
- Trace textarea1 to both counter elements.
- Type and paste text to observe the input listener.
- Change maxlength and verify both counters.
Editable original
Opening editor…
LIVE PREVIEW
Console 0
Your console output appears here.
Saved on this deviceJavaScript · ES2022
Notes on this source port
- Use the input event so paste and speech input update the original counters; label the textarea and remove autofocus.
Make it your own
The original works. These are your next experiments.
- Count Unicode code points instead of UTF-16 units.
- Add a warning state near the limit.