当前位置:网站首页>Form form of the uniapp uview framework, input the verification mobile number and verification micro signal
Form form of the uniapp uview framework, input the verification mobile number and verification micro signal
2022-06-10 18:28:00 【Sit and wait for the sunset time】
effect

Code implementation
<u-form :model="form" ref="form">
<u-form-item label-width="150" label=" contact number " prop="contactNumber"><u-input v-model="form.contactNumber" placeholder=" Please enter the contact number " maxlength="11" /></u-form-item>
<u-form-item label-width="150" label=" WeChat ID " prop="wxAccount"><u-input v-model="form.wxAccount" placeholder=" Please input the micro signal " /></u-form-item>
</u-form>The micro signal is only verified with or without Chinese
<script>
import api from '@/api/api.js';
export default {
data() {
return {
form: {},
rules: {
// cell-phone number
contactNumber: [
{
required: false,
},
{
// Custom validation functions
validator: (rule, value, callback) => {
// return true Indicates that the verification is passed , return false Say no
// Filter the first layer , First judge that the input is not empty , because required: false, Not required , So if it is empty, it should return true
if(value) {
return this.$u.test.mobile(value);
} else {
return true
}
},
message: ' The mobile number is incorrect ',
// Triggers can be used simultaneously blur and change
trigger: ['change','blur'],
}
],
// WeChat ID
wxAccount: [
{
required: false,
},
{
// Custom validation functions
validator: (rule, value, callback) => {
// return true Indicates that the verification is passed , return false Say no
if(value) {
let i = 0;
// Cycle to check whether each character is Chinese
for(i=0;i<value.length;i++) {
if(this.$u.test.chinese(value[i])) {
return false;
}
}
return true;
} else {
return true
}
},
message: ' Please do not enter Chinese characters ',
// Triggers can be used simultaneously blur and change
trigger: ['change','blur'],
}
]
}
};
},
methods: {
handleSubmit() {
const that = this;
const params = {
wxAccount: this.form.wxAccount,
contactNumber: this.form.contactNumber
};
// Form start verification
this.$refs.form.validate(valid => {
// by true, To perform the next operation , by false, Will show rules Inside message
if (valid) {
api.shopUpdate(params).then(res => {
if (res.code === '00000') {
uni.showModal({
title: ' Tips ',
content: ' Modification successful ',
showCancel: false,
success() {
that.getInfo();
}
});
}
});
}
});
},
},
onShow() {
},
onReady() {
// Form setting verification rules
this.$refs.form.setRules(this.rules);
}
};
</script>边栏推荐
- Developers changing the world - Yao Guang teenagers playing Tetris
- YML file configuration parameter definition dictionary and list
- 数据的软删除—什么时候需要?又如何去实现?
- 一道题讲解动态规划的前世今生
- c语言---3 初识变量
- 改变世界的开发者丨玩转“俄罗斯方块”的瑶光少年
- Can the "no password era" that apple is looking forward to really come true?
- Wireshark学习笔记(一)常用功能案例和技巧
- 微信小程序仿陶票票课程设计
- 基于智慧路灯杆打造智慧社区物联网
猜你喜欢

AFL fuzzy multithreading

Talk about those things about telecommuting, participate in the essay solicitation, receive the contribution fee and win the grand prize!

作为程序员,对于底层原理真的有那么重要吗?

Red vertical left side menu navigation code

vcsa7u3c安装教程

商业智能BI如何帮企业降低人力、时间和管理成本?

VMware esxi version number comparison table

微信小程序,获取当前页面,判断当前页面是不是tabbar页面

c语言---3 初识变量

二叉树之Morris遍历
随机推荐
CodeCraft-22 and Codeforces Round #795 (Div. 2)
Win7系统下无法正常安装JLINK CDC UART驱动的问题解决
两部门发文明确校外培训机构消防安全条件
云计算搭建全部内容总结,保证可以搭建一个完整的云计算服务器,包括节点安装、实例的分配和网络的配置等内容
(CVPR 2020) RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
【技术分析】探讨大世界游戏的制作流程及技术——前期流程篇
afl-fuzz多线程
Developers changing the world - Yao Guang teenagers playing Tetris
Data URL
flutter系列之:UI layout简介
光储直柔配电系统浅析
muduo源码剖析——以三个切片浅析muduo库代码设计的严谨性、高效性与灵活性
AOE网关键路径
VMware ESXi 各版本号对照表
一道题讲解动态规划的前世今生
换根呀呀啊呀
商业智能BI的服务对象,企业管理者的管理“欲望”该如何实现?
CodeCraft-22 and Codeforces Round #795 (Div. 2)
c语言---6 初识选择语句、循环语句、函数以及数组
不确定性推理:让模型知道自己不知道