天天看點

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去驗證呗,呵呵. 貌似小題大作了一番,沒辦法;剛自己居然被一個非空驗證

弄啥了,汗......

繼續閱讀