手机号自动加空格 银行卡号自动加空格
银行卡号 加空格代码
<input maxlength="19"
@keyup="accNoDispose"
type="text"
placeholder="请输入银行卡号"
v-model="addNewCardNum">
accNoDispose: function () {
if (this.addNewCardNum.length > 4) {
let beforeSix = this.addNewCardNum.substring(0, 4);
let afterNum = this.addNewCardNum.substring(4, this.addNewCardNum.length);
this.addNewCardNum =beforeSix +" "+afterNum.replace(/\s/g, "")
.replace(/\D/g, "")
.replace(/(\d{4})(?=\d)/g, "$1 ");
}
}
手机号 自动加空格
<input maxlength="13" @keyup="PhoneDispose" class="phoneNum" type="text" placeholder="输入银行预留手机号" v-model="phoneNum">
PhoneDispose: function () {
// 手机号 添加 间隙
if (this.phoneNum.length > 3) {
let beforeSix = this.phoneNum.substring(0, 3);
let afterNum = this.phoneNum.substring(3, this.phoneNum.length);
this.phoneNum =
beforeSix +
" " +
afterNum
.replace(/\s/g, "")
.replace(/\D/g, "")
.replace(/(\d{4})(?=\d)/g, "$1 ");
}
},