在网上找一个合适的代码并与你分享。
复制代码代码如下所示:
判断FCK / /内容是空的
无功oeditor = fckeditorapi.getinstance('content'); / /内容是FCK的ID
如果(长度(内容)< = 0){
警报(内容不能为空!)
oeditor焦点();
返回false;
}


函数长度(STR){
无功oeditor = fckeditorapi.getinstance(STR);
无功checkcontent = oeditor.editordocument;
无功contentlength;
如果(文件all){
contentlength = checkcontent.body.innertext.trim(长度);
}
别的{
VAR r = checkcontent.createrange();
r.selectnodecontents(checkcontent。体);
contentlength = r.tostring()。修剪长度();
}
返回contentlength;
}

去掉字符串空间
string.prototype.trim =功能()
{
返回(this.replace /(^ { } *)|({ } * $)/ g,);
}