I use Kendo Editor in the body text for email and I don't know how to set and get error message for Kendo Editor.
I set the maximum length to 8000 for the body text and when copy and paste more than 8000 characters into it, it will show a error message "Body Text is required" which is not correct. The error should be something like "The text must be less than 8000 characters."
Here is my code.
In Form.cshtml
<form id="email" class="hidden"> <ul> <li class="k-state-active">Email</li> <li>Preview</li> </ul> <div> ...... @Html.DecoratedField(x => x.AssignEmail.BodyText, required: true, maxLength: 8000, type: "textarea") ...... </div> <button id="action" type="button" class="k-primary k-button">Save and Preview</button> <button id="backButton" type="button" class="k-button">Back to List</button> @Html.AntiForgeryToken()</form>
In Form.chhtml.cs
[HttpPost] public async Task<IActionResult> OnPostAssignMail([FromQuery] int sessionId, [FromForm] AssignEmailSaveModel model) {. . . . . . AssignEmail = new AssignEmail() { BodyText = model.Body, };. . . . . . }
In AssignEmail.cs
namespace assign.intranetv2.Models{ [Table("Emails")] public class AssignEmail { ... ... [StringLength(8000)] [Required] public string BodyText { get; set; } ... ... }}
In Javascript
// INITvar bodyEditor = emailBodyKendoEditorSetup();var emailBodyKendoEditorSetup = function () { return $('#AssignEmail_BodyText').kendoEditor().data('kendoEditor');};
