JavaScript gets the value of the CKEditor editor (Implementation code) _javascript tips

Source: Internet
Author: User

The CKEditor Editor is an upgraded version of FCKeditor
Think for FCK, it is really easy to use, loading speed is also relatively fast
The following is for form validation if you get the value of the CKEditor editor through JS

if (CKEDITOR.instances.content.getData () = = "") {
Alert ("Content cannot be empty!") ");
return false;
}

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

Just a friend of the response that Firefox can not be judged empty, I slightly modified the next
My test in FF passed, the following is the JS code
function Trim (str) {
Return Str.replace (/(^/s*) | ( /s*$)/g, "");
}//Remove Space
var str=ckeditor.instances.content.getdata ();
Str=str.replace ("<br/>", "");
Str=str.replace ("<br>", "");
Str=trim (str);
if (str== "") {
Alert ("Content cannot be empty!") ");
return false;
}

Specifically in the use of the combination, thank the friend of the proposed

/*

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

The eval () function computes a string and executes the JavaScript code in it. (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.