This is my HTML code for the data filed 'Body':
<textarea asp-for="Body" id="Body" class="form-control" rows="10"></textarea>
<br class="p-0 m-0" />
<span asp-validation-for="Body" class="text-danger"></span>
Java script to enable jquery validation for ASP.NET CORE MVC with CKeditor:
<script type="text/javascript">
// replace textarea with CKEDITOR for editing data field 'Body'
CKEDITOR.replace('Body');
// this function make working standard jquery validation with CKEDITOR
$(document).ready(function () {
CKEDITOR.instances['Body'].on('key', function () {
CKEDITOR.instances['Body'].updateElement();
// Fire validation to update standard validation messages
$('form').valid();
//alert(CKEDITOR.instances["Body"].getData());
});
});
// this allow you to avoid double form submission
$('#postForm').on('submit', function () {
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].updateElement();
}
});
// allow CKEDITOR to work with standard jquery validation (switch on validation for the hidden fields)
$.validator.setDefaults({ ignore: '' });
</script>