I have added a RichtextCheckbox custom field in Sitecore forms.


I have added validation and it's working fine.

This is the razor code

<label class="@Model.LabelCssClass">
    <input type="checkbox" id="@Html.IdFor(m => Model.IsChecked)" name="@Html.NameFor(m => Model.Value)" class="@Model.CssClass" @if (Model.IsChecked) { <text> checked="checked" </text> } value="true" data-sc-tracking="@Model.IsTrackingEnabled" data-sc-field-name="@Model.Name" />@Html.DisplayTextFor(t => Model.Title)
    @Html.ValidationMessageFor(m => Model.Value)

I want to override the validation error message. Currently, if the checkbox is not checked then the error is "is required". I want to override the error message. How can I do that?

Has anyone done something similar?


That is the default error message for mandatory fields. This blog post describes how you can change that:

The code for the required field validation works in a different way and the message will come from the Sitecore dictionary. If you want to update or translate it, you need to add a key to that Dictionary. This can be done in the master database - just add an item in the /system/Dictionary - the name doesn't really matter. The key however needs to be exactly "{0} is required.". The phrase can be anything you want, just remember to add the {0} token. enter image description here

Note that this would change the message for all mandatory fields.

If you want something specific, you'll need to create a custom validation. You can read here or here how.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy