// Textarea text counter to limit the field length function textBoxCounter(textAreaInput, counterDisplayId, maxTextLength) { if (textAreaInput.value.length > maxTextLength) { // if too many characters are in the field remove the excess! textAreaInput.value = textAreaInput.value.substring(0, maxTextLength); } else { // if the user has characters remaining update the counter to show how many. document.getElementById(counterDisplayId).innerHTML = maxTextLength - textAreaInput.value.length; } }