FCK判断内容是否为空(如果只是去空格,那么这种方式是错误的)

2023-12-05 0 730

在网上找到一段合适的代码,与大家分享。 复制代码 代码如下: //判断fck的内容是否为空 var oEditor = FCKeditorAPI.GetInstance(\’content\’); //这里的content是FCK的ID值 if(GetLength(\”content\”)<=0) { alert(\’内容不能为空!\’); oEditor.Focus(); return false; } function GetLength(str){ var oEditor = FCKeditorAPI.GetInstance(str) ; var checkContent= oEditor.EditorDocument ; var contentLength ; if ( document.all ){ contentLength= checkContent.body.innerText.trim().length ; } else{ var r = checkContent.createRange() ; r.selectNodeContents( checkContent.body ) ; contentLength= r.toString().trim().length ; } return contentLength; } //去掉字符串的空格 String.prototype.trim = function() { return this.replace(/(^[\\s]*)|([\\s]*$)/g, \”\”); }

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 网页编辑器 FCK判断内容是否为空(如果只是去空格,那么这种方式是错误的) https://www.u-9.cn/biancheng/bianji/97202.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务