理念:
最近我实现了一个名为NicEdit的所见即所得编辑器,它将我所有的textareas改为NicEdit所见即所得(基本上,它是一个论坛。所以实现一个所见即所得的编辑器会让用户感觉轻松)。我按照这样的方式对我的textarea进行了编程,你会得到一个警告框,说“#34;请在身体里输入一些东西"如果你点击提交而不输入任何内容。如果你输入内容并发帖,你将被重定向到你发布的页面。
问题:
现在我在实施NicEdit wysiwyg编辑器后面临一个问题。当我在textarea中输入内容并点击提交时,会发生以下情况
我不希望弹出警报框。
代码:
<script src="js/nicEdit.js"></script>
<script>bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
nicEdit.js很长。我按照NicEdit的安装指南进行操作,它要求我只包含上面两行代码。但在我这样做之后,我面临着上述问题。
任何实施NicEdit的人都面临同样的问题?如果是这样,请建议我一个解决方案。
修改
这是我页面中的html内容。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $forum_section_title; ?></title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="style/forumstyle.css">
<!--<link rel="stylesheet" href="style/editor.css">-->
<script src="js/main.js"></script>
<script src="js/ajax.js"></script>
<!--<script src="js/nicEdit.js"></script>
<script>bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
<!--<script src="js/editor.js"></script>-->
<script src="ckeditor/ckeditor.js"></script>
<script>
function validateMyForm ( )
{
var isValid = true;
if ( document.form1.post_title.value == "" )
{
alert ( "Please type in a title for this topic" );
isValid = false;
}
else if ( document.form1.post_title.value.length < 10 )
{
alert ( "Your title must be at least 10 characters long" );
isValid = false;
}
else if ( document.form1.post_body.value == "" )
{
alert ( "Please type in your topic body." );
isValid = false;
}
return isValid;
}
/*function submit_form(){
var theForm = document.getElementById("form1");
theForm.elements["post_body"].value = document.getElementsByClassName("nicEdit-selected").innerHTML;
theForm.submit();
}*/
</script>
</head>
<body>
<?php include_once("template_pageTop.php"); ?>
<div id="pageMiddle">
<div id="leftPanel">
<a href="viewFriends.php"><img src="images/friendsImage.png" ></a>
<a href="photos.php"><img src="images/galleryImage.png" ></a>
<a href="messages.php"><img src="images/messagesImage.png"></a>
<a href="forumhome.php"><img src="images/forumImage.png"></a>
</div>
<div id="middlePanel">
<table style="background-color:#FFF; border:#069 1px solid; border-top:none;" width="100%" border="0" align="center" cellpadding="12" cellspacing="0">
<tr>
<td width="80%" valign="top">
<h2><?php echo $forum_section_title; ?></h2>
<div id="breadcrumbs"><a href="forumhome.php">Forum</a>←<a href="sections.php?id=<?php echo $forum_section_id; ?>"><?php echo $forum_section_title; ?></a></div><br /><br />
<h2>Creating New Topic In the <em><?php echo $forum_section_title; ?></em> Forum</h2>
<form action="php_parsers/forumpost_system.php" method="post" name="form1" id="form1">
<input name="post_type" type="hidden" value="a" />
Topic Author:<br /><input name="topic_author" type="text" disabled="disabled" maxlength="64" style="width:96%;" value="<?php echo $log_username; ?>" />
<br /><br />
Please type in a title for your topic here:<br /><input name="post_title" type="text" maxlength="64" style="width:96%;" /><br /><br />
Please type in your topic body:<br />
<textarea name="post_body" id="post_body" rows="15" style="width:96%;"></textarea>
<script>
CKEDITOR.replace( 'post_body' );
</script>
<!--<iframe name="richTextField" id="richTextField" style="border:#000000 1px solid; width:700px; height:300px;"></iframe>-->
<br /><br />
<input name="" type="submit" value="Create my topic now!" onclick="validateMyForm();"/>
<input name="fsid" type="hidden" value="<?php echo $forum_section_id; ?>"/>
<input name="fstitle" type="hidden" value="<?php echo $forum_section_title; ?>"/>
<input name="uid" type="hidden" value="<?php echo $log_id; ?>"/>
<input name="uname" type="hidden" value="<?php echo $log_username; ?>"/>
<input name="upass" type="hidden" value="<?php echo $log_password; ?>"/>
</form>
</td>
<td width="20%" valign="top"> </td>
</tr>
</table>
</div>
<div id="rightPanel"></div>
</div>
<?php include_once("template_pageBottom.php"); ?>
</body>
</html>
答案 0 :(得分:0)