天天看点

FCK 非空验证

项目中用了个FCK 文本编辑框

看起来简洁,用起来也还不错.

Java代码

  1. <script src="js/formValidator.js" type="text/javascript" charset="UTF-8"></script>   
  2. <script src="js/fckeditor.js" type="text/javascript" charset="UTF-8"></script>   
  3. <textarea  rows="20" name="article.content"  class="input_text" id="article_content" style="width:600px;" ></textarea>   
  4.     <!--<fck:editor instanceName="article.content"    
  5.       height="400px" width="600px"></fck:editor>-->   
  6.          <script type="text/javascript">   
  7.              var oFCKeditor = new FCKeditor('article_content') ;   
  8.              oFCKeditor.BasePath = "fckeditor/" ;   
  9.              oFCKeditor.Height = 200;   
  10.              oFCKeditor.ToolbarSet = "My" ;   
  11.              oFCKeditor.EnterMode = "" ;     
  12.              oFCKeditor.ShiftEnterMode = "br" ;   
  13.              oFCKeditor.ReplaceTextarea();   
  14.             </script>  
<script src="js/formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/fckeditor.js" type="text/javascript" charset="UTF-8"></script>



<textarea  rows="20" name="article.content"  class="input_text" id="article_content" style="width:600px;" ></textarea>
    <!--<fck:editor instanceName="article.content" 
      height="400px" width="600px"></fck:editor>-->
         <script type="text/javascript">
             var oFCKeditor = new FCKeditor('article_content') ;
             oFCKeditor.BasePath = "fckeditor/" ;
             oFCKeditor.Height = 200;
             oFCKeditor.ToolbarSet = "My" ;
             oFCKeditor.EnterMode = "" ;  
             oFCKeditor.ShiftEnterMode = "br" ;
             oFCKeditor.ReplaceTextarea();
            </script>
           

做非空和长度限制验证的时候 发现获得的aiticle_content对象的value总是处于初始化状态

不解.明明输入了很多值;怎么就不能验证了 想了想是不是JQuery的问题 或者浏览器的问题

写了个 document.getElementById("article_content").value;

居然也没值,汗..

弄了半天才想起来,呗FCK托管了嘛,当然是找FCK取值咯.

原来要这么取值,汗.

Java代码

  1. var content = FCKeditorAPI.GetInstance("article_content").GetXHTML(true);  
var content = FCKeditorAPI.GetInstance("article_content").GetXHTML(true);
           

ok 拿着content去验证呗,呵呵. 貌似小题大作了一番,没办法;刚自己居然被一个非空验证

弄啥了,汗......

继续阅读