Aliaspooryorik
ColdFusion ORM Book

ValidateThis and CKEditor

I'm just working on a site that uses the CKEditor WYSIWYG editor and ValidateThis and wanted to make the content required. In the past I've done something like I showed in my post Validate CKEditor content length. The problem is that the client side validation that ValidateThis creates, validates against the hidden formfield that CKEditor uses and not the actual contents of the editor. I considered several possible options, including writing a custom client side validation for ValidateThis, however, in the end I went for this simple solution:


$('form').bind('submit', function(){
if (typeof CKEDITOR != "undefined"){
for (instance in CKEDITOR.instances){
CKEDITOR.instances[instance].updateElement();
}
}
});

 


2 comments

  1. John, I was curious if you had tackled the issue of having the validation message disappear if the user enters some text into the CKEditor, ie normal input/textarea behavior.

    Comment by Jim Priest – October 31, 2011
  2. Hi Jim, I know that CKEditor has DOM events which you could potentially use, but I'm haven't tried. Sorry! docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.event.html

    Comment by John Whish – November 01, 2011

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts