I am using CLEditor in my application for rich text that the user will fill in.
When I validate the textarea element in my PHP server side script, I do all the checking e.g. if the element is empty.
There is a problem with this in that the source of the text editor sometimes remains despite the text being cleared.
Here is an example of what I mean:
Say I have a rich text editor as shown below and I have the heading 'write your first page!'.
Here is how the source looks for the above picture:
Then when I remove the text only and NOT any empty lines remaining, the source around the text remains as shown below:
The PHP empty
function is going not going to pass as it's technically not empty because of the source code contained in the text editor.
The issue with this is I cannot rely on the user to clear the whole screen including empty lines, so is there a way I can get rid of any source that doesn't contain actual content as the second image above shows?
HTML:
<textarea id="textarea" name="chapter"><h4 style="text-align: center;">Write your first page!</h4></textarea>
if(empty($_POST['chapter']){...}
with the above, it will always return false because it contains html tags but no actual content within them. So is there a way around that? – user3574492