当前位置:网站首页>Vee validate validation
Vee validate validation
2022-04-21 07:09:00 【Garfield cat】
install vee-validate
cnpm install vee-validate
establish zh_CN.js( Copy the content )
export default {
after: (field, [target]) => ` ${field} Must be in ${target} after `,
alpha_dash: (field) => ` ${field} Can contain alphanumeric characters , Including dashes 、 Underline `,
alpha_num: (field) => `${field} Can only contain alphanumeric characters .`,
alpha_spaces: (field) => ` ${field} Can only contain alphabetic characters , Including Spaces .`,
alpha: (field) => ` ${field} Can only contain alphabetic characters .`,
before: (field, [target]) => ` ${field} Must be in ${target} Before .`,
between: (field, [min, max]) => ` ${field} Must be in ${min} ${max} Between .`,
confirmed: (field, [confirmedField]) => ` ${field} Unable to join ${confirmedField} matching .`,
date_between: (field, [min, max]) => ` ${field} Must be in ${min} and ${max} Between .`,
date_format: (field, [format]) => ` ${field} Must be in ${format} In the format .`,
decimal: (field, [decimals] = ['*']) => ` ${field} It must be numeric and can contain ${decimals === '*' ? '' : decimals} decimal point .`,
digits: (field, [length]) => ` ${field} It has to be numbers , Accurate to ${length} Count `,
dimensions: (field, [width, height]) => ` ${field} Must be ${width} Pixels to ${height} Pixels .`,
email: (field) => ` ${field} Must be a valid mailbox .`,
ext: (field) => ` ${field} Must be a valid file .`,
image: (field) => ` ${field} It must be a picture .`,
in: (field) => ` ${field} Must be a valid value .`,
ip: (field) => ` ${field} Must be a valid address .`,
max: (field, [length]) => ` ${field} Not greater than ${length} character .`,
mimes: (field) => ` ${field} Must be a valid file type .`,
min: (field, [length]) => ` ${field} There must be at least ${length} character .`,
not_in: (field) => ` ${field} Must be a valid value .`,
numeric: (field) => ` ${field} Can only contain numeric characters .`,
regex: (field) => ` ${field} Invalid format .`,
required: (field) => `${field} Is a must .`,
size: (field, [size]) => ` ${field} Must be less than ${size} KB.`,
url: (field) => ` ${field} It's not effective url.`
}
main.js Add in
import VeeValidate, { Validator } from 'vee-validate'
// Quote Chinese tips
import zh from './components/vee-validate/zh'
Vue.use(VeeValidate, {
locale: 'zh'
})
Validator.addLocale(zh)
Validator.extend('phone', {
messages: {
zh: ' Please enter the correct mobile phone or fixed line ( Format : Area code - Telephone )'
},
validate: value => {
return value.length === 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value) || /^(\d{3}-)(\d{8})$|^(\d{4}-)(\d{7})$|^(\d{4}-)(\d{8})$/.test(value)
}
})
Validator.extend('email', {
messages: {
zh: ' Please enter the correct email address '
},
validate: value => {
return /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/.test(value)
}
})
const dict = {
zh: {
custom: {
email: {
required: ' The mailbox cannot be empty ' // messages can be strings as well.
},
phone: {
required: ' Mobile phone cannot be empty '
},
company: {
required: ' Company name cannot be empty '
},
uname: {
required: ' Contact cannot be empty '
},
duty: {
required: ' Job information cannot be empty '
},
code: {
required: ' Verification code cannot be empty '
}
}
}
}
Validator.updateDictionary(dict)
html Use in
<ul>
<li>
<span> Contact name </span>
<input type="text" v-validate="'required'" :class="{'input': true, 'is-danger': errors.has('uname') }" name="uname" ref="name" class="inputSty" placeholder=" Please enter the contact name ">
<b>*</b>
</li>
<li v-show="errors.has('uname')" class="is-danger">{
{ errors.first('uname') }}</li>
<li>
<span> contact number </span>
<input type="text" v-validate="'required|phone'" :class="{'input': true, 'is-danger': errors.has('phone') }" name="phone" ref="tel" class="inputSty" placeholder=" Please enter mobile phone or fixed line ( Format : Area code - Telephone )">
<b>*</b>
</li>
<li v-show="errors.has('phone')" class="is-danger">{
{ errors.first('phone') }}</li>
<li>
<span> Contact email </span>
<input type="text" v-validate="'required|email'" name="email" :class="{'input': true, 'is-danger': errors.has('email') }" ref="mail" class="inputSty" placeholder=" Please enter the contact email ">
<b>*</b>
</li>
<li v-show="errors.has('email')" class="is-danger">{
{ errors.first('email') }}</li>
</ul>
版权声明
本文为[Garfield cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210612153862.html
边栏推荐
- shell 语言中的 if 条件判断
- Modify the launcher3 icon and add a mask or shadow icon to the icon
- Launcher3 secondary development modification removes drawers, displays icons in workspace, deletes Google search box and other operations.
- gojs 无水印版
- Li Kou video note 21 - depth first search method + 938 question method
- imx6调试Lvds屏幕技术笔记
- Code implementation of feature pyramid transformer
- ESP32 LVGL8.1 ——btn 按钮 (btn 15)
- canvas 绘制路飞
- idea如何打包成war包
猜你喜欢

Flat (flat lattice transformer) code implementation

notepad ++ 将制表符(tab)替换为空格

Differences between STM32, gd32 and esp32

Official account version update and introduction

ROS入门学习笔记(二)

I2C protocol (I): I2C bus spec
![3、 0 [Verilog HDL] first acquaintance with Verilog programming language](/img/bd/6352e3b12f4f4997d5342bbaec2b9a.jpg)
3、 0 [Verilog HDL] first acquaintance with Verilog programming language

Teach you how to use I2C tools

Qt中自定义提示框messageBox
![2、 2 [FPGA] development environment construction](/img/7a/e6904f1685d92e4fd716487fb63456.png)
2、 2 [FPGA] development environment construction
随机推荐
Construction of deep learning environment - Installation of Anaconda (used with vscode) and tensorflow GPU versions
Neural network reasoning processing of MNIST data set
jeecg boot微服务架构图
每日CISSP认证常错题(2022年4月19日)
UCOSIII移植和使用,参考正点原子
R | create LEGO mosaic
Sublime Text3 安装简体中文
3、 3 basic concepts of [Verilog HDL] basic knowledge
Detailed steps and explanation of converting MNIST data into numpy array format
3.bat中date命令问题
The random gradient descent method is used to learn the depth network
Launcher3 secondary development modification removes drawers, displays icons in workspace, deletes Google search box and other operations.
Using numpy library to realize convolution network from scratch and complete the recognition of MNIST handwritten data set
ESP32 (UART 接收发送)-串口之接收发送通讯(4)
ESP32 LVGL8.1 ——arc 圆弧 (arc 19)
const关键字、变量、函数用const修饰
Modify the launcher3 icon and add a mask or shadow icon to the icon
Spark性能优化指南
ROS入门学习笔记(一)
ESP32 LVGL8.1 ——msgbox 消息框 (msgbox 28)