Reputation: 1521
I have a CKEDITOR Text area. The field will never be empty because the CKEDITOR always write
<p> </p>
also if the field contains no user input.
Is there a way to check if the field is empty (no user input)? Because: $_POST['textarea'] == '' returns false also if user input is null.
Upvotes: 1
Views: 2287
Reputation: 8347
Well, if it consistently adds the <p> </p>
how about this?
if (in_array($_POST['textarea'], array('<p> </p>', '')))
or:
if (str_replace('<p> </p>', '', $_POST['textarea']) == '')
This will also return true if the user inadvertently presses enter
, but doesn't add any text.
EDIT:
You can take this as far as you like, depending on your notion of "empty input":
if (trim(str_replace(' ', '', strip_tags($_POST['textarea']))) == '')
etc.
EDIT some more:
Turns out this has been discussed before: Validate FCKEditor blank or not
Upvotes: 1