HTML页面代码
JS代码
KindEditor.ready(function(K) {
window.editor = K.create('#editor_id');
var options = {
cssPath : '/css/index.css',
filterMode : true
};
var editor = K.create('textarea[name="con"]', options);
// 取得HTML内容
html = editor.html();
// 同步数据后可以直接取得textarea的value
editor.sync();
html = document.getElementById('editor_id').value; // 原生API
html = K('#editor_id').val(); // KindEditor Node API
html = $('#editor_id').val(); // jQuery
// 关闭过滤模式,保留所有标签
KindEditor.options.filterMode = false;
KindEditor.ready(function(K) {
K.create('#editor_id');
});
});
编辑器已经发布到服务器中了,该配置的都配置好了,那我应该怎么去判断现在的文本域不能为空?
在普通文本域我之前用的JS现在失效了
function form(){
if(document.f.tit.value.length==0){
alert("标题不能为空!");
document.f.tit.focus();
return false;
}
if(document.f.con.value.length==0){
alert("内容不能为空!");
document.f.con.focus();
return false;
}
}
现在就是不知道怎么去改JS判断是否为空了
这是HTML代码
问题已经解决了,原来是我的表单验证没有同步数据的原因,加上editor.sync();就好了