当前位置:网站首页>uview表单,身份证,键盘,实时验证
uview表单,身份证,键盘,实时验证
2022-07-20 01:11:00 【曲帅369】
<u-form-item label="身份证号" prop="card" ref="card">
<u-input v-model="form.card" placeholder="请输入身份证号" @click="keyCardShow = true" />
<u-keyboard ref="uKeyboardCard" mode="card" v-model="keyCardShow" @change="valChangeCard" @backspace="backspaceCard" :mask="false">
</u-keyboard>
</u-form-item>
rules: {
card: [{
required: true,
message: '请输入身份证',
trigger: ['blur','change'],
},
{
// 自定义验证函数
validator: (rule, value, callback) => {
// 返回true表示校验通过,返回false表示不通过
return this.$u.test.idCard(value)
},
message: '身份证不正确',
// 触发器可以同时用blur和change
trigger: ['blur','change'],
}
],
}
valChangeCard(val) {
// 将每次按键的值拼接到value变量中,注意+=写法
this.form.card += val;
this.triggerSingleFieldValidate("card")
},
// 退格键被点击
backspaceCard() {
// 删除value的最后一个字符
if (this.form.card.length) this.form.card = this.form.card.substr(0, this.form.card.length - 1);
this.triggerSingleFieldValidate("card")
},
//验证
triggerSingleFieldValidate(refName) {
setTimeout(()=>{
this.$refs[refName].onFieldChange()
},200)
}
边栏推荐
- 开发测试平台难吗?
- [translation] dynamic query in C # expression
- AVL 树
- Example of conventional deployment configuration of Huawei campus network
- Xshell&&putty配色方案
- 企业在什么情况下有引入分布式数据库的必要性?
- 苦劝无果,民警现场写代码揭诈骗,这事让我有一个脑洞
- 语音信号处理:采样定理【只要采样频率大于或等于有效信号最高频率的两倍,采样值就可以包含原始信号的所有信息,被采样的信号就可以不失真地还原成原始信号】
- Win11新Bug任务栏图标不显示的解决方法
- CCTV news news "Suzhou restaurant manual tearing quota invoice" news channel_ People's network
猜你喜欢
Three principles CIOs should follow in order to successfully carry out digital transformation
Arduino读取传感器数据存进Excel中
PX4使用P900数传
Persuasion failed, and the police wrote code to expose the fraud on the spot, which made me have a brain hole
Changjiang Dayong, director of opengauss community: opengauss cooperates with industry innovation to build an open source database root community
Example of conventional deployment configuration of Huawei campus network
LeetCode_90_子集Ⅱ
小程序:页面滚动到某个位置导航条固定效果
哈希表(HashTable)
Protocol buffer learning
随机推荐
Changjiang Dayong, director of opengauss community: opengauss cooperates with industry innovation to build an open source database root community
CCTV news "Nanjing rent quota invoice by hand" news channel_ People's network
动态内存管理+柔性数组
英伟达NX使用笔记
Internet of things communication protocols: mqtt, COAP, nb-iot, RFID, Bluetooth, NFC
C asynchronous programming read this article is enough
CCTV news news news channel of Guangzhou catering manual tearing quota invoice_ People's network
[translation] dynamic query in C # expression
CCTV news news news channel of Shenzhen catering manual tearing quota invoice_ People's network
CCTV news "Chengdu opens catering quota invoice by hand" news channel_ People's network
如何运用并行编程Parallel提升任务执行效率
弃用 Notepad++,这款开源替代品更牛逼!
苦劝无果,民警现场写代码揭诈骗,这事让我有一个脑洞
Information system project manager core examination center (46) procurement statement of work (SOW)
【JVM 系列】JVM 中常见的垃圾回收器
Main research directions of Intelligent Question Answering
Makefile详解
Web APIs DOM event delegation + comprehensive case
C#异步编程看这篇就够了
Model compression - scheme (I) - parameter sharing: Albert, Bert of Theseus