jshtml
function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else countfield.value = maxlimit - field.value.length; }
htmlspa
<form name=myform action=""> <textarea name="message" cols="28" rows="5" onKeyDown="textCounter(message,remLen,1000);" onKeyUp="textCounter(message,remLen,1000);"></textarea> 您還能夠輸入:<input name="remLen" type="text" value="1000" size="5" readonly="readonly">個字符 </form>