0

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 should be invalid (null data) both at client side (js - jquery 1.4.2) and server side (php 5)?

thanks

mana
  • 1
  • 2
  • The best way to determine an 'empty' input in terms of it containing no actual presentational data would likely be a regular expression. – Nathan Taylor Oct 26 '10 at 19:31

1 Answers1

1

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,"") == ""){
}
Community
  • 1
  • 1
Petah
  • 45,477
  • 28
  • 157
  • 213