gpt4 book ai didi

php - nicEdit 文本区域的默认值

转载 作者:可可西里 更新时间:2023-10-31 23:06:52 25 4
gpt4 key购买 nike

代码如下

<?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 输入任何文本,它会显示 length=4。为什么会这样? nicedit textarea 有默认值吗?如果是,如何更改?

最佳答案

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

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

关于php - nicEdit 文本区域的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15896157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com