当前位置:网站首页>el-form-item 正则验证
el-form-item 正则验证
2022-07-01 13:47:00 【一个假的前端男】
<el-form-item label="商品名称" prop="name">
<el-input type="text" v-model.trim="param.name" style="width:640px" @change="handleChange" maxlength="30" ></el-input>
</el-form-item>
rules:{
name: [
{
validator: (rule, value, callback) => {
console.log(value, 'lail ')
if (!value) {
callback(new Error('请输入商品名称'))
} else {
let chinese = []
let noChinese = []
chinese = value.split('').filter(item => {
return /^[\u4e00-\u9fa5]{0,}$/.test(item) === true
})
noChinese = value.split('').filter(item => {
return /^[\u4e00-\u9fa5]{0,}$/.test(item) !== true
})
var num = chinese.length * 2 + noChinese.length
console.log(num)
if (num < 4 || num > 30) {
callback(new Error('请输入2到15个汉字。'))
}
}
},
trigger: 'blur',
required: true
}
],
}
边栏推荐
- Dragon lizard community open source coolbpf, BPF program development efficiency increased 100 times
- 7. Icons
- ArrayList capacity expansion mechanism and thread safety
- 20个实用的 TypeScript 单行代码汇总
- Six years of technology iteration, challenges and exploration of Alibaba's globalization and compliance
- Content Audit Technology
- Etcd 概要 机制 和使用场景
- 详细讲解面试的 IO多路复用,select,poll,epoll
- 盲盒NFT数字藏品平台系统开发(搭建源码)
- uni-app实现广告滚动条
猜你喜欢

【Flask】Flask启程与实现一个基于Flask的最小应用程序
![[NLP] pre training model - gpt1](/img/bd/9803ad946b33159de51b93106a2151.png)
[NLP] pre training model - gpt1

Application of 5g industrial gateway in scientific and technological overload control; off-site joint law enforcement for over limit, overweight and overspeed

2022上半年英特尔有哪些“硬核创新”?看这张图就知道了!

Interpretation of R & D effectiveness measurement framework

AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集

04 redis source code data structure dictionary

QT学习管理系统

建立自己的网站(21)

minimum spanning tree
随机推荐
小程序-小程序图表库(F2图表库)
陈宇(Aqua)-安全-&gt;云安全-&gt;多云安全
Application of 5g industrial gateway in scientific and technological overload control; off-site joint law enforcement for over limit, overweight and overspeed
Analysis report on the development trend and Prospect of new ceramic materials in the world and China Ⓐ 2022 ~ 2027
Station B was scolded on the hot search..
5. Use of ly tab plug-in of header component
开源实习经验分享:openEuler软件包加固测试
C语言基础知识
3.4 data query in introduction to database system - select (single table query, connection query, nested query, set query, multi table query)
SAP 智能机器人流程自动化(iRPA)解决方案分享
Leetcode question 1: sum of two numbers (3 languages)
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
spark源码(五)DAGScheduler TaskScheduler如何配合提交任务,application、job、stage、taskset、task对应关系是什么?
Analysis report on the development prospect and investment strategy of the global and Chinese laser chip industry Ⓑ 2022 ~ 2027
[anwangbei 2021] Rev WP
Simplex, half duplex, full duplex, TDD and FDD
Summary of interview questions (1) HTTPS man in the middle attack, the principle of concurrenthashmap, serialVersionUID constant, redis single thread,
[Jianzhi offer] 55 - ii balanced binary tree
Report on the current situation and development trend of bidirectional polypropylene composite film industry in the world and China Ⓟ 2022 ~ 2028
7. Icons