0

I have CKEditor wysiyg. Once user submits the article, i do the following:

if(!ctype_space($_POST['rtxt_article']))
{
     //do something

}

The above code makes sure the input has some actual character(s) and its not a plain whitespaces. Its works well with regular textarea. However, it doesn't work with wysiyg.

I'm using CKEditor, once user clicks submit. The code hits //do something and ctype_space has no effect at all.

I check the HTML source, i found the output as whitespaces, no characters at all, so i wonder why ctype_space doesn't work with wysiyg textarea.

The output, after fetching the article from db, would look like this:

<div id="textcontent">                       </div>

Any idea?

hakre
  • 193,403
  • 52
  • 435
  • 836
user311509
  • 2,856
  • 12
  • 52
  • 69
  • Did you find an actual lack of characters (and so 'just' white-space), or just non-printing characters (such as, for an example, those listed here: http://stackoverflow.com/questions/1627481/how-many-non-printing-characters-are-in-common-use/1627502#1627502)? – David Thomas Nov 19 '11 at 19:41
  • In the HTML Source code (after calling the posted article from db), i see blank spaces as of " " - discard the quotations. – user311509 Nov 19 '11 at 19:44

1 Answers1

2

The wysiwyg might add some kind of (empty) HTML tags or even transform whitespaces with the entity &nbsp;.

Try following check:

if (trim(strip_tags($_POST['rtxt_article'])) != "") {
  // do something
}

This will also catch unwanted input like

<p></p>
<div></div>

etc.

MiDo
  • 1,057
  • 1
  • 7
  • 11