使用时CKEDITOR
with <textarea>
标签,它不起作用。
<textarea id="editor1" name="description" class="form-control" cols="10" rows="10" required></textarea>
<script>
CKEDITOR.replace('editor1');
</script>
有什么建议么?
请参见:https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_editor.html#event-required https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_editor.html#event-required
您需要为 CKEditor 分配一个事件处理程序来“替换”本机textarea
元素。
如果您正在寻找比标准警报对话框更奇特的显示消息的方式,请尝试使用通知 https://docs.ckeditor.com/ckeditor4/latest/guide/dev_notifications.html。下面是最基本的示例(当您按submit
按钮,当编辑器为空时,将显示通知):
var editor = CKEDITOR.replace( 'editor1', {
language: 'en',
extraPlugins: 'notification'
});
editor.on( 'required', function( evt ) {
editor.showNotification( 'This field is required.', 'warning' );
evt.cancel();
} );
请注意,与文档中所写的相反notification
插件似乎包含在每个预设中。您可以使用搜索框进行检查Available Plugins
,列表框在在线构建器 https://ckeditor.com/cke4/builder.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)