<p class="label">邮箱</p>
<!-- :rules="[{ required: true, message: `请输入${ele.name}` }]" -->
<p>
<van-field
v-model="staff_number"
name="staff_number"
placeholder="请输入邮箱"
@blur="handleEmailInput"
/><span style="color:red;margin-top:.16rem;display:block;">*后缀必须是henkel.com</span>
</p>
handleEmailInput(event) {
const inputValue = event.target.value;
const isValid = this.validateEmail(inputValue);
if (!isValid) {
// 处理错误逻辑
this.staff_number = ''
this.$toast("邮箱后缀必须是henkel.com", 'error')
return
}
},
validateEmail(email) {
const regexPattern = /henkel\.com$/;
if (!email) {
return false; // 为空时直接返回false
}
return regexPattern.test(email);
},
网友评论