jquery - How to validate joomla 2.5 default text editor? -
how validate joomla default text editor on blur using jquery?
this code used text editor. example, in /models/forms/newsitem.xml:
<field name="description" type="editor" buttons="true" hide="pagebreak,readmore,article,image" class="inputbox required" filter="jcomponenthelper::filtertext" label="jglobal_description" description="com_newsitems_field_description_desc" required="true" />
and sec file (/views/.../edit.php) - new object add together javascript?
<script type="text/javascript"> joomla.submitbutton = function(task) { if (task == 'newsitem.cancel' || document.formvalidator.isvalid(document.id('newsitem-form'))) { <?php echo $this->form->getfield('description')->save(); ?> joomla.submitform(task, document.getelementbyid('newsitem-form')); } else { alert('<?php echo $this->escape(jtext::_('jglobal_validation_form_failed'));?>'); } } </script>
what want want show warning message next text editor saying "you can't leave blank". can in form submit real challenge how on blur.
this code document.formvalidator.isvalid(document.id('newsitem-form'))
validates form if editor there in form can seek this-
jquery('#editorid').blur(function() { if(!document.formvalidator.isvalid(document.id('newsitem-form'))){ //add error message code } });
update:-
jquery(jquery('iframe')[0].contentwindow).blur(function() { var editor_text = jquery('iframe').contents().find('body').text(); if(editor_text=='')alert('error message'); });
note:-use valid selector points editor iframe work if there 1 editor
hope help.
jquery joomla validation joomla2.5
No comments:
Post a Comment