当前位置:网站首页>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>边栏推荐
- 记录一个超级乌龙的智障bug,也许能帮助类似我的白吃
- VMware vCenter 各版本号对照表
- Custom types: structural bodies
- c语言---2 初识数据类型
- 低碳数据中心建设思路及未来趋势
- 干货 | 一文搞定 uiautomator2 自动化测试工具使用
- Talk about those things about telecommuting, participate in the essay solicitation, receive the contribution fee and win the grand prize!
- Memory pool principle I (based on the whole block)
- MYSQL开窗函数详解
- 【数据库】结构化数据、非结构化数据、半结构化数据的区别
猜你喜欢

Developers changing the world - Yao Guang teenagers playing Tetris

Faster Planner——Kinodynamic Astar详解

Detailed explanation of MySQL windowing function

c语言---8 初识常见关键字

ETL的使用过程中遇到的坑(ETL中文乱码)

After the qtmqtt source code compilation is set to keepalive, the Ping package timeout error does not return a problem repair (qmqtt:: mqttnopingresponse, qmqtt:: clientprivate:: onpingtimeo)

pwnable start

ACL2022 | bert2BERT:参数复用的高效预训练方法,显著降低超大模型的训练成本

VMware ESXi 各版本号对照表

数据可视化入门学习,要警惕陷阱误区,把握关键节点
随机推荐
攻防演练 | 网络安全“吹哨人”:安全监控
阅读micropyton源码-添加C扩展类模块(4)
【QNX Hypervisor 2.2 用户手册】3.2.1 VM配置语法
【QNX Hypervisor 2.2 用户手册】3.2.2 VM配置示例
基础提升---树形DP补充
华为云鲲鹏DevKit代码迁移实战
vcsa7u3c安装教程
期货网上开户安全吗,具体怎么开户的
c语言学习回顾---1 基础知识回顾
作为程序员,对于底层原理真的有那么重要吗?
如何定位游戏发热问题
Adding rendererdata of URP with script
c语言---6 初识选择语句、循环语句、函数以及数组
Set up an online help center to easily help customers solve problems
Developers changing the world - Yao Guang teenagers playing Tetris
Win7系统下无法正常安装JLINK CDC UART驱动的问题解决
uniapp uview 框架的form表单,输入校验手机号、校验微信号
阅读micropyton源码-添加C扩展类模块(2)
商业智能BI的服务对象,企业管理者的管理“欲望”该如何实现?
VMware ESXi 各版本号对照表