码迷,mamicode.com
首页 > 其他好文 > 详细

veeValidate

时间:2017-09-11 15:10:37      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:res   ref   xquery   current   erro   highlight   efault   object   out   

网站

http://vee-validate.logaretm.com/index.html#about

 

自定义为空时候的提示

Field-specific Custom Messages

You might need to provide different messages for different fields, for example you might want to display an error message for the email field when its required, but a different messsage when the name is required. This allows you to give your users a flexible experience and context aware messages.

To do this you would need to add an object to the dictionary called custom like this:

const dict = {
  en: {
    custom: {
      email: {
        required: ‘Your email is empty‘ // messages can be strings as well.
      },
      name: {
        required: () => ‘Your name is empty‘
      }
    }
  }
};

Notice that the custom object contains properties that represent the field names, those field names objects contain properties that represent the validation rule that its value will be used instead of the default one.

Then you would need to add the dictionary we just constructed to the current validators dictionary like this:

Validator.updateDictionary(dict);
// or use the instance method
this.$validator.updateDictionary(dict);

veeValidate

标签:res   ref   xquery   current   erro   highlight   efault   object   out   

原文地址:http://www.cnblogs.com/yang-C-J/p/7504779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!