I'm using the ckeditor 3.4 as text editor for my website, and want to validate the data at client side first, before submitting the data to server.
I can get the data of editor by using this code: var editorData = CKEDITOR.instances.editor1.getData();
but having trouble to validate data. The problem is: - The data should be invalid if user didn't enter anything into editor or enter only some space or line break (null data)
by default, CKEDITOR.instances.editor1.getData() return <br />
if user didn't type anything and return
<p>
</p>
<br />
if user enter a line break (may be many <p> </p>
if user enter many line break)
please help me to check this case should be invalid (null data) both at client side (js - jquery 1.4.2) and server side (php 5)?
thanks
Look up How do you check for an empty string in JavaScript?
Specifically:
var str = $('<p> </p> <br />').text();
if(str.replace(/\s/g,"") == ""){
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.