当前位置:网站首页>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
}
],
}
边栏推荐
- Word2vec training Chinese word vector
- Chen Yu (Aqua) - Safety - & gt; Cloud Security - & gt; Multicloud security
- 二传感器尺寸「建议收藏」
- JVM有哪些类加载机制?
- Listen in the network
- Build a vc2010 development environment and create a tutorial of "realizing Tetris game in C language"
- Machine learning summary (I): linear regression, ridge regression, Lasso regression
- 机器学习总结(一):线性回归、岭回归、Lasso回归
- Spark source code reading outline
- Analysis report on production and marketing demand and investment forecast of global and Chinese diamond powder industry Ⓤ 2022 ~ 2027
猜你喜欢

【Flask】Flask启程与实现一个基于Flask的最小应用程序

一文读懂TDengine的窗口查询功能
![[NLP] pre training model - gpt1](/img/bd/9803ad946b33159de51b93106a2151.png)
[NLP] pre training model - gpt1

MySQL 66 questions, 20000 words + 50 pictures in detail! Necessary for review
![[flask] flask starts and implements a minimal application based on flask](/img/45/77df241c85c4916914a37bb78275a5.png)
[flask] flask starts and implements a minimal application based on flask

9. Use of better scroll and ref

【NLP】预训练模型——GPT1

Six years of technology iteration, challenges and exploration of Alibaba's globalization and compliance

AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集
![[241. Design priority for operation expression]](/img/72/29d27204d5213a8efdb2c5be925dec.png)
[241. Design priority for operation expression]
随机推荐
Understand the window query function of tdengine in one article
Global and Chinese n-butanol acetic acid market development trend and prospect forecast report Ⓧ 2022 ~ 2028
孔松(信通院)-数字化时代云安全能力建设及趋势
[安网杯 2021] REV WP
04-Redis源码数据结构之字典
Global and Chinese polypropylene industry prospect analysis and market demand forecast report Ⓝ 2022 ~ 2027
详细讲解面试的 IO多路复用,select,poll,epoll
MySQL 66 questions, 20000 words + 50 pictures in detail! Necessary for review
1.8新特性-List
[machine learning] VAE variational self encoder learning notes
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
刘对(火线安全)-多云环境的风险发现
“国防七子”经费暴增,清华足足362亿元,甩第二名101亿 |全国高校2022预算大公开...
小程序- view中多个text换行
Camp division of common PLC programming software
C语言课程设计题目
队列的基本操作(C语言实现)
[Jianzhi offer] 54 The k-th node of binary search tree
Animesr: learnable degradation operator and new real world animation VSR dataset
Word2vec training Chinese word vector