Home > Web Front-end > JS Tutorial > body text

JavaScript gets the value of the ckeditor editor (implementation code)_javascript skills

WBOY
Release: 2016-05-16 17:14:39
Original
1091 people have browsed it

CKeditor editor is an upgraded version of FCKeditor
For FCK, it is indeed easier to use and the loading speed is faster
The following is the value of CKeditor editor obtained through JS for form verification

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

content is the name of the textarea
Next time I will post the CKeditor configuration and upload configuration. I only uploaded it in PHP

A friend just reported that it cannot be judged as empty under FIREFOX. I modified it slightly
My test passed 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("
","");
str=str.replace("
","");
str=trim(str) ;
if(str==""){
alert("Content cannot be empty!");
return false;
}

The specific combination is in use. Thank you to this friend for suggesting it

/*

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

The

eval() function evaluates a string and executes the JavaScript code within it. (A very important function)

var cke_arr = CKEDITOR.instances;
eval("var cke_content = CKEDITOR.instances." ta_id ".getData();");

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template