首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FCKeditor %1验证不起作用

FCKeditor %1验证不起作用
EN

Stack Overflow用户
提问于 2014-03-18 12:44:12
回答 1查看 75关注 0票数 0

我正在使用FCKeditor上传数据库中的数据

代码如下..

代码语言:javascript
复制
<?php
    // Automatically calculates the editor base path based on the _samples directory.
    // This is usefull only for these samples. A real application should use something like this:
    // $oFCKeditor->BasePath = '/fckeditor/' ;  // '/fckeditor/' is the default value.
    $sBasePath = $_SERVER['PHP_SELF'] ;
    $sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;
    $oFCKeditor = new FCKeditor('FCKeditor1') ;
    $oFCKeditor->Height = 400;
    $oFCKeditor->BasePath   = $sBasePath ;
    $oFCKeditor->Value= "";
    $oFCKeditor->Create() ;
?>

和Javascript用于验证的不允许数据字段为空的使用情况如下..

代码语言:javascript
复制
    <script type="text/javascript">
    function validatearticle() {
    if (document.addtwebinar_frm.FCKeditor1.value == "")
       {
          alert("Please Enter Article Data!");
          document.addtwebinar_frm.FCKeditor1.focus();
          return false;  
       }
    }
    </script>

所示的javascript部分是脚本的一部分。同样形式的其他值和验证,例如文章主题、文章作者等正在得到验证。但即使在将fckeditor字段保留为空之后,表单仍会被提交。

请在代码或javascript上提供帮助。

EN

回答 1

Stack Overflow用户

发布于 2014-03-18 13:34:15

尝试使用trimming删除文本中的空格。

代码语言:javascript
复制
<script type="text/javascript">
function validatearticle() {
if (document.addtwebinar_frm.FCKeditor1.value.trim() === "")
   {
      alert("Please Enter Article Data!");
      document.addtwebinar_frm.FCKeditor1.focus();
      return false;  
   }
}
</script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22470577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档