Javascript to get the value of the ckeditor Editor (implementation code)

Source: Internet
Author: User

CKeditor editor is an upgraded version of FCKeditor.
For FCK, it is really easy to use and the loading speed is faster.
The following example shows how to obtain the value of the CKeditor editor through JS for form verification.

If (CKEDITOR. instances. content. getData () = ""){
Alert ("content cannot be blank! ");
Return false;
}

Content is the name of textarea
Next time I send CKeditor configuration and upload configuration, I only get PHP Upload

A friend said that the field cannot be determined to be blank in FIREFOX. I modified it a little.
I passed the test under FF. The following is the JS Code.
Function trim (str ){
Return str. replace (/(^/s *) | (/s * $)/g ,"");
} // Remove Spaces
Var str = CKEDITOR. instances. content. getData ();
Str = str. replace ("<br/> ","");
Str = str. replace ("<br> ","");
Str = trim (str );
If (str = ""){
Alert ("content cannot be blank! ");
Return false;
}

In use, combine them. Thank you for your suggestion.

 

/*

**************************************** ***********************************/

The eval () function computes a string and executes the JavaScript code. (A very important function)

Var cke_arr = CKEDITOR. instances;
Eval ("var cke_content = CKEDITOR. instances." + ta_id + ". getData ();");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.