邮箱验证必须以什么结尾

2023-07-27  本文已影响0人  泪滴在琴上
<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);
    },
上一篇 下一篇

猜你喜欢

热点阅读