开发者

check the data of ckeditor is null or not

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>
 &nbsp;</p>
<br />

if user enter a line break (may be many <p>&nbsp;</p> if user enter many line break)

please help me to check this case s开发者_运维百科hould 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> &nbsp;</p> <br />').text();
if(str.replace(/\s/g,"") == ""){
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜