vue.js怎么用正则校验手机号?

vue.js怎么用正则校验手机号?下面本篇文章给大家介绍一下vue.js手机号正则表达式验证。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

vue.js手机号正则表达式验证

getCode() {
        if (this.mobile === '') {
          this.$vux.toast.show({
            type: 'text',
            text: '请输入手机号',
            time: 2000
          });
          this.selected = true;
        } else {
          if (!/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[7]))\d{8}$/.test(this.mobile)) {
            this.$vux.toast.show({
              type: 'text',
              width: '10em',
              text: '手机号格式不正确',
              time: 2000
            })
          } else {
            this.selected = false;
            this._count();
            this.$store.dispatch('SystemManage/getCode', {
              module: 'changePasswordByMobile',
              mobile: this.formObj.mobile
            }).then(() => {
              if (this.$store.state.SystemManage.model) {
                this.$vux.toast.show({
                  type: 'text',
                  text: '发送成功',
                  time: 2000
                })
              }
            });
          }
        }
      },

更多web前端知识,请查阅 HTML中文网 !!

以上就是vue.js怎么用正则校验手机号?的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Vue.js 答疑