Show how many characters remaining in a HTML text box using JavaScript
问题 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? 回答1: Dynamic HTML element functionThe code in here with a little bit of modification and simplification: <input disabled maxlength="3" size="3"