2

After linking the script directory to "ckeditor5", I have text-area as follow :

<textarea rows="10" name="sample_identity" id="sample_identity" Placeholder="Sample Identification" data-parsley-required="true"></textarea>

And, this creates the ckeditor replacing the textarea.

<script>ClassicEditor.create( document.querySelector( '#sample_identity' ) )</script>

Now, how do I make this "sample_identity" instance of ckeditor required on form submit.

I tried using the class for the ckeditor instance which is-

.ck-focused for onfocus and .ck-blurred on outfocus.

But, I have 3-4 textareas on the same form which has ckeditor replacing them. So, this'll not work.

I know ckeditor5 is a betaversion an hasn't been used yet, but, any help on this would be appreciated.

Thank you.

4

1 回答 1

1

您现在需要手动处理。特别是你使用Parsley,我猜 CKEditor 隐藏原始文件会混淆<textarea>它(CKEditor 仅将其用作数据源,然后将其隐藏以插入自己的容器)。

默认情况下,CKEditor 更新<textarea>表单提交时的 ' 值。这意味着当有人在此表单中按下提交按钮时,该回调将导致当前编辑器的数据与表单的其余部分一起发送到服务器。

但是,这可能不适用于本机验证(我还没有检查过),并且很少有机会使用一些自定义验证框架。

这意味着您需要手动处理验证。这意味着您需要在表单上收听例如submit事件,获取编辑器的数据,检查是否正常。如果是,就什么也不做。如果没有,请阻止事件的默认操作并向用户显示一些信息。

当然,这只是其中一种选择。您需要自己为您的案例找出正确的解决方案。

于 2017-12-29T10:39:35.020 回答