Modification or localization of validation messages in Sitecore Forms


Description

The Sitecore Forms application does not allow modifying or localizing validation messages for fields. The client-side validation is implemented using default jQuery libraries. You can try the following solution to change validation messages for mandatory fields.

Solution

To localize validation messages for mandatory fields:

  1. Download a file of the corresponding client translation from dev.sitecore.net compatible with the affected version of the Sitecore XP product.
  2. Click Control Panel, Localization, Import Languages, choose the file you have downloaded, and install the client translation both to the Master and the Web databases of your instance.
  3. Open the corresponding localization item and change the text in the Phrase field.

 

For example:

  1. Download the Danish (da-DK) client translation for Sitecore XP 9.2 Initial Release.
  2. Click Import Languages and choose the client translation you have just downloaded, and install the Danish (da-DK) file to the Master and Web databases.
  3. The validation messages for mandatory fields are taken from the /sitecore/system/Dictionary/0/0 is required item depending on its language version. So you can change the Phrase field's value in the required language version of this item and publish it:
    {0} er påkrævet
  4. Note that these entries could be cached in the \temp\dictionary.dat file, so you can try to remove it and reset your App Pool if the changes have not been applied.

Sitecore supports only 4 translations by default: Danish (da-DK), German (de-DE), Japanese (ja-JP), and Chinese (zh-CN). You can add additional languages using the instructions from Add a new language to Sitecore settings and Create a different language version of a Sitecore Form articles.