Ckeditor|<;文本区域&>标记内的";必需";属性不工作 [英] ckeditor | the "required" attribute within <textarea> tag is not working
本文介绍了Ckeditor|<;文本区域&>标记内的";必需";属性不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将CKEDITOR
与<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
您需要为CKEditor分配一个事件处理程序,以"替换"本机textarea
元素。
如果您希望使用比标准警报对话框更别致的方式显示消息,请尝试使用notifications。下面是最基本的例子(当您在空的编辑器中按
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
的搜索框、online builder中的列表框进行查看。
这篇关于Ckeditor|<;文本区域&>标记内的";必需";属性不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文