2010-06-30 41 views
1

我使用joomla默認編輯器的窗體和jquery驗證插件,現在我想驗證joomla文本編輯器不應該是空白....我如何驗證?如何驗證joomla默認的文本編輯器?

我讀到一篇文章關於確認對TinyMCE的,我想類似this post

但如果我上比驗證工作切換編輯器點擊(怎麼把它變成teaxarea),但是當存在的Joomla默認的編輯器,然後不顯示任何錯誤,當它是空白

這裏是reuired代碼

<script type="text/javascript"> 
jQuery(document).ready(function(){ 
    jQuery("#addBookForm").validate({ 
     rules: {    
      description: "required"    
     }, 
     messages: {   
      description:"Please write description",   
     } 
    }); 
}); 
</script> 
<form id="addBookForm" action="" method="post" >  
    <table width="100%" border="0" cellpadding="4" cellspacing="2"> 
     <tr> 
      <td>Description :</td> 
      <td > 
     <?php 
      $editor =& JFactory::getEditor(); 
      $params = array('smilies'=> '0' ,'style' => '0' ,'layer' => '0' ,'table' => '0' ,'clear_entities'=>'0'); 
      $value = isset($this->data['description']) ? $this->data['description'] : ''; 
      echo $editor->display('description', $value,'400','300','20','20',false, $params); 
     ?> 
      </td> 
     </tr>  
    </table>  
</form> 

回答

2

您可以通過添加以下代碼爲視圖實現這一

$js="function validateEditor(){ 
     var content = ".$editor->getContent('editorName')."; 
     return content;     
    }"; 
$document =& JFactory::getDocument(); 
$document->addScriptDeclaration($js); 

在提交表單之前調用這個java腳本函數(validateEditor)。

+0

我沒有測試你的代碼(我離開Joomla項目)......無論如何感謝解決方案 – diEcho 2011-01-24 13:14:54

相關問題