This is my code:
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) {
field.value = field.value.substring(0, 160);
field.blur();
field.focus();
return false;
} else {
countfield.value = maxlimit - field.value.length;
}
}
How can I display how many characters are remaining from a certain text box with a limit of 160?
Dynamic HTML element functionThe code in here with a little bit of modification and simplification:
Hope this helps!
tip:
When merging the codes with your page, make sure the HTML elements(
textarea,input) are loaded first before the scripts (Javascript functions)