Prefilled error message for custom validator

Vote:
 

We have a custom validator called BankgiroValidator and with that a language file in wwwroot/Resources/LanguageFiles/ that looks like this:

<language>
   <episerver>
      <forms>
         <validators>
            <[namepsace].BankgiroValidator>
               <displayname>Bankgiro</displayname>
               <message>Enter a correct bankgiro</message>
            </[namepsace].BankgiroValidator>
         </validators>
      </forms>
   </episerver
</language

The validator inherits ElementValidatorBase and does not override BuildValidationModel(IElementValidatable targetElement).

Now the error message "Enter a correct bankgiro" shows up correctly when using the form on the website. Also if we use a custom error message for that particular field when choosing the validator, that works too. But we'd like to prefill the field for the custom error message with our fallback error message as well, just like it does for the RequiredValidator (which is the one called "Obligatorisk" in the screenshot):

Any ideas on how to achieve this?

#218292
Mar 10, 2020 15:02
Vote:
 

Hi,

I try to create a custom validator with localization declare, and when I check into the validtor, default message filled to the text box. Pls try to correct your language file, I guess there is something missing there.

#218967
Mar 26, 2020 8:12
Vote:
 

Late answer to this post. I also encountered this issue today.

Just in case it helps someone else later:

Ensure that the resource XML definition is using ALL lowercase texts, e.g.

<language>
   <episerver>
      <forms>
         <validators>
            <namespace.bankgirovalidator>
               <displayname>Bankgiro</displayname>
               <message>Enter a correct bankgiro</message>
            </namespace.bankgirovalidator>
         </validators>
      </forms>
   </episerver>
</language
#263154
Sep 15, 2021 9:06
Vote:
 

I also have the same case.

#263402
Sep 20, 2021 12:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.