如何验证 joomla 默认文本编辑器?
我使用 joomla 默认编辑器作为表单和 jquery 验证器插件,现在我想验证 joomla 文本编辑器不应该为空......我该如何验证?
我读了一篇关于tinymce验证的文章,我想要类似于这篇文章
虽然如果我点击切换编辑器比验证有效(因为它变成了teaxarea),但是当有joomla默认编辑器时,当它为空时不会显示任何错误,
这是所需的代码
<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>
i m using joomla default editor for a form and jquery validator plugin, now i want to validate that joomla text editor should not be blank.... how do i validate that??
i read an article regarding validation for tinymce, i want similar to this post
although if i click on toggle editor than validation works( coz it turn into teaxarea) but when there is joomla default editor then does not display any error when it is blank
here is the reuired code
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个老问题,但仍然相关,并且仍然很难找到直接的答案。
您可以仅通过 JavaScript 轻松检查编辑器是否为空:
其中 myid = 编辑器字段 id
This is an old question but still relevant and still difficult to find a straightforward answer.
You can easily check whether the editor is empty via javascript only:
where myid = editor field id
您可以通过为视图添加以下代码来实现此目的
,并在提交表单之前调用此 java 脚本函数 (validateEditor)。
You can achieve this by adding the following code for your view
And call this java script function (validateEditor) before submitting the form.