Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Angel Santos angelsantosa

🎯
Focusing
View GitHub Profile
@angelsantosa
angelsantosa / textarea_limit_characters_vanilla.js
Last active Jan 9, 2019
A simple textarea delimiter and counter using Vanilla Javascript http://jsfiddle.net/yru532m4/
View textarea_limit_characters_vanilla.js
let textareas = document.querySelectorAll('.limit-text')
Array.from(textareas).forEach(el => {
let maxlength = el.getAttribute('maxlength')
el.parentNode.querySelectorAll('.count_message')[0].innerHTML = maxlength + ' remaining'
el.addEventListener('keyup', function(event) {
let length = this.value.length
let text_remaining = maxlength - length