undefinedfix
Sign in

How to operate Vue Vee validate

ugowz edited in Wed, 03 Aug 2022

Vee is used in the project - Validate, now in normal use, such as:

<input class="phone intlPhone" type="text" placeholder="请输入手机号"onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" 
maxlength=11 v-validate="'required|phone'" name="phone" v-model="regphone">
 <span class="veetips" v-show="errorBags.has('phone')" v-if="phoneshow">
      {{ errorBags.first('phone')}}
 </span>

This can be used normally, and it can also verify the correct rules of mobile phone. But now there is a problem, that is, when I call the interface, I need to prompt such a prompt statement as "this mobile phone number is not registered" (there will be more prompts in Shenzhen)

How should I operate the content in this span

This is validate.js In the user-defined statements, but can only define the format, how do I combine the interface to use it, I hope which boss help to solve the next

// Mobile validator . extend (' phone ', { getMessage : field => ' Wrong format of mobile phone number ', validate : value => value . length === eleven && /^(( thirteen | fourteen | fifteen | seventeen | eighteen )[ zero - nine ]{ one } d { eight })$/. test ( value )});

1 Replies
user282
commented on Wed, 03 Aug 2022

If you look for the official API, there should be a user-defined verification method similar to validator, in which you can write the logic of calling Ajax verification