关于昨天的问题,我今天在写的时候查看vaildform和kindeditor文档发现具体的解决办法.
首先昨天说的第一个用onblur()是有BUG的,第二种方法会提交两次表单数据!!!可耻的匿了。。。果然实践是检验真理的唯一途径。。。下面给出具体的解决代码:
<script language="javascript">
//kindEditor
var editor
KindEditor.ready(function(K) {
editor = K.create('textarea[name="about_content"]', {
cssPath : '__ROOT__/kindeditor/plugins/code/prettify.css',
uploadJson : '__ROOT__/kindeditor/php/upload_json.php',
fileManagerJson : '__ROOT__/kindeditor/php/file_manager_json.php',
allowFileManager : true,
afterBlur: function(){this.sync();},
afterCreate : function() {
var self = this;
K.ctrl(document, 13, function() {
self.sync();
K('form[name=about_example]')[0].submit();
});
K.ctrl(self.edit.doc, 13, function() {
self.sync();
K('form[name=about_example]')[0].submit();
});
}
});
});
$(function(){
$(".registerform").Validform({
beforeCheck:function(curform){
editor.sync();
if(editor.isEmpty()){
alert("FCK不能为空");
return false;
}
},
beforeSubmit:function(curform){
editor.sync();
if(editor.isEmpty()){
alert("FCK不能为空");
return false;
}
},
});
})
</script>