1

I am using Sitecore 9.0.1 and I have created a Sitecore Form (not WFFM). I want to add a custom error messages to the fields. Below are the steps which I followed to add error message for Email:

1.created a custom validator called Email Validation here: /sitecore/system/Settings/Forms/Validations/Email Validation

enter image description here

  1. Selected the newly created validation here: /sitecore/system/Settings/Forms/Field Types/Basic/Email

enter image description here

3.Under the Form field "Email" I changed the validator to "Email validation" enter image description here

But still I am able to see the default English error message.

enter image description here

So I followed this other answer https://sitecore.stackexchange.com/questions/17905/sitecore-forms-email-field-validation-message-is-showing-in-english-instead-of-k and downloaded the zip file and placed it in my Sitecore instance \sitecore modules\Web\ExperienceForms\scripts folder and added the script under my Renderbody() and reverted my changes and made my form to use email validator but still I'm getting the same English error message for other fields but some different error for email field.

enter image description here

@using Sitecore.Mvc
@using Sitecore.ExperienceForms.Mvc.Html
@using Sitecore.Mvc.Analytics.Extensions
@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" href="~/Assets/Form.css" />
    <title>@Html.Sitecore().Field("title", new { DisableWebEdit = true })</title>
    @Html.Sitecore().VisitorIdentification()
    @Html.RenderFormStyles()
    @Html.RenderFormScripts()
</head>
<body>
    @RenderBody()
    <script type="text/javascript">
        var lang = '@Sitecore.Context.Language.Name';
        var script = document.createElement("script");
        if (lang == 'zh-cn')
        {
            script.src = "/sitecoremodules/Web/ExperienceForms/scripts/localization/messages_zh.js";
            $("head").append(script);
        }
    </script>
</body>
</html>

Can anyone please guide where I am going wrong?

Thanks

0

To translate Forms error messages you need two translations: one for the front-end messages (javascript) and one for the back-end messages from Sitecore.

I think you already have the FE covered by following that other SSE answer (https://sitecore.stackexchange.com/a/18075/237) which directs you to my blog post on the subject: https://ggullentops.blogspot.com/2019/04/sitecore-9-forms-translating-client-error.html.

From your screenshot I think your main issue is the required fields. And that is indeed a special one. It's covered in my other post on translating error messages: https://ggullentops.blogspot.com/2017/10/sitecore-9-forms-translating-error.html

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. Translate and publish...

3
  • for the required field i created chinese version for form required and published for other fields validation is working for chinese language but for email and other fields which has other validations it is still showing the english error message
    – Vinaya
    Apr 16 at 16:28
  • The blogs explain how to do the translation. You need to verify where the message comes from (javascript or Sitecore). If they come from Sitecore you can search for the message and translate it. I'm afraid that without seeing your solution, we cannot do that debugging for you..
    – Gatogordo
    Apr 16 at 16:37
  • the message is coming form this script " jquery.validate.min.js" i removed this from my form after removing no message is coming except required fields message @Gatogordo
    – Vinaya
    Apr 16 at 17:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.