加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – nicEdit textarea的默认值

发布时间:2020-12-13 17:16:01 所属栏目:PHP教程 来源:网络整理
导读:这是一个代码 ?php if (isset($_POST['flag'])) { $length=strlen(trim($_POST['area'])); echo "Length of abstract : ".$length; if (!strlen(trim($_POST['area']))){ $abstractErrorMsg = "Please enter the abstract of your article"; echo $abstractE
这是一个代码

<?php 
if (isset($_POST['flag'])) {

    $length=strlen(trim($_POST['area']));
     echo "Length of abstract  :  ".$length;
     if (!strlen(trim($_POST['area']))){
        $abstractErrorMsg = "Please enter the abstract of your article";
        echo $abstractErrorMsg;
    }
}
?>
<form method="post" action="">
        <input type="hidden" name="flag" value="hidden">
        <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> 
        <script type="text/javascript">
                            //<![CDATA[
                            bkLib.onDomLoaded(function() {
                                nicEditors.editors.push(
                                        new nicEditor().panelInstance(
                                        document.getElementById('myNicEditor')
                                        )
                                        );
                            });
                            //]]>
                        </script>

                        * Abstract

                                <textarea name="area" id="myNicEditor" style="width: 300px;height: 100px;"></textarea>

        <input type="submit" name="btn">
    </form>

如果我在没有输入任何文本到nicedit textarea的情况下提交表单,则显示长度= 4.
为什么会这样?nicedit textarea有默认值吗?如果是,如何改变它?

解决方法

通过评论3行解决问题.在niceEdit.js中搜索以下代码.默认情况下,它包含< br />.

init : function() {
            this.elm.setAttribute('contentEditable','true');    
            //if(this.getContent() == "") {
            //  this.setContent('<br />');
            //}
            this.instanceDoc = document.defaultView;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读