New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAQ:如何校验KindEditor #74

Closed
vincentchen opened this Issue Oct 25, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@vincentchen
Copy link

vincentchen commented Oct 25, 2013

类似的富文本编辑器如何校验

@niceue

This comment has been minimized.

Copy link
Owner

niceue commented Oct 25, 2013

@vincentchen
只要是表单控件,niceValidator都可以验证。
众多的编辑器都是基于textarea控件的。对于KindEditor它通过iframe创建了一个隔离的可视化编辑环境,但是它编辑的内容不会实时同步,也就是说你内容编辑完了,textarea的值却还是空的。但是,当你提交表单的时候,KindEditor会同步内容。
可以看下KindEditor的官方说明:我取不到编辑器数据,直接取得textarea的value也没用

所以在验证初始化中调用beforeSubmit,并同步一下编辑器的内容,就可以验证了,代码如下:

$("#form").validator({
    beforeSubmit: function(){
        editor.sync();
    }
});

@niceue niceue closed this Jan 26, 2016

@jaychang9

This comment has been minimized.

Copy link

jaychang9 commented Mar 30, 2016

不错,果然可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment