代码如下
<?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/