ちょっとしたものだがフォームのテキストエリアに使うと
結構便利なのでメモ![]()
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 + "文字";
}