ちょっとしたものだがフォームのテキストエリアに使うと


結構便利なのでメモひらめき電球


onkeyupとonfocusに使用するといい感じにできる。


こんな感じ

onkeyup="strLengthCount(value, 'textcount');"

onfocus="strLengthCount(value, 'textcount');"


/**

* javascriptでリアルタイムにテキストエリアの文字数をカウントする

*/
//value テキストエリアのvalue

//outid 表示するID
function strLengthCount(value, outid) {

 document.getElementById(outid).innerHTML = "文字数:" + value.length + "文字";

}