0

Imagine I have two forms, each has email field required. I want to:

  1. Show different validation messages for each form
  2. Be able to localize them

Why do I need this: for example, when user signs up and doesn't fill out email field I want to display something like: "Please, specify your email. We will send you some instructions to this email so that you know how to proceed".

On the other hand, when user is in his profile and tries to change his email, I can just tell him: "Email is required field" or something like that.

Plus, I need to localize both of them.

I know that I can specify custom messages for name attributes for each field, but it'll mean that all forms will use them. However I want to be able to have more control. Actually I have localization files in my app, like en_US.json, ru_RU.json, and each form is placed inside an object, with its labels, placeholders etc, plus there is a validation object.

So, is it possible at all?

Victor
  • 5,073
  • 15
  • 68
  • 120
  • localization is built into the library: [see here](https://baianat.github.io/vee-validate/guide/localization.html) – LShapz May 07 '18 at 21:16
  • And how can I have two validation messages for the same field localized? For example "We need your email" and "Email is required", depending on form? – Victor May 08 '18 at 11:21
  • I think in that case you just need to give the two forms slightly different names, like email-unregistered and email-login? – LShapz May 08 '18 at 15:27
  • Okay, but when specifying messages you specify only rules, like "required" and attributes (which are email-login, email-unregistered). But this way it's still not possible to make custom messages which has different template.. – Victor May 08 '18 at 16:36

0 Answers0