使用Javascript计算用户当前输入的字符数函数代码:








统计字符数

功能countwords(obj,show_id){
Var fullStr = obj.value;
无功charcount = fullstr.length;
VaR Rexp = / / GI就^ } {;
无功spacesstr = fullstr.replace(Rexp,');
无功cleanedstr = spacesstr +;
做{
无功old_str = cleanedstr;
cleanedstrcleanedstr = cleanedstr.replace(',');
}而(old_str!= cleanedstr);
无功splitstring = cleanedstr.split('');
document.getelementbyid(show_id).innerHTML = charcount;
}







零




javascript实现的统计字符数非常简单,上面共享的代码可以直接使用,希望能帮到大家学习。