<input class="CDkey-input" @blur="onKeyInput" v-model="CDkeyValue" type="text" maxlength="12" placeholder="请输入或粘贴兑换码(数字和大写字母组成)" />
data() {
return {
CDkeyValue: '',
};
},
methods: {
// 失去焦点兑换码验证
onKeyInput() {
console.log(this.CDkeyValue);
if (this.CDkeyValue != '') {
this.getCardTypeNumber(this.CDkeyValue);
}
},
// 兑换码正则验证 必须是大写字母和数字组成
getCardTypeNumber(value) {
const reg = /^[0-9A-Z]+$/;
if (!reg.test(value)) {
uni.showToast({
icon: 'none',
title: '请输入正确的兑换码',
duration: 2000,
position: 'top',
});
} else {
console.log('兑换码格式正确');
}
},
},
uniapp 输入框兑换码正则验证只能大写字母和数字
最新推荐文章于 2024-05-24 20:59:17 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)