vue 之手机号验证、正则验证手机号是否正确、手机号验证码信息弹窗

vue 之手机号验证、正则验证手机号是否正确

项目介绍:
首先 项目是为了获取用户手机号码,其次 验证手机号后才可评论也是为了不让用户乱评论;

在这里插入图片描述
2.在这里插入图片描述
填写评论后,弹出提交手机号、验证码弹窗;填写手机号后获取验证码,输入验证码正确后,才可提交评论;

// 1.判断评论内容不为空,出验证手机号弹窗;
posttijiao () {
   
      if (this.plcontent == "") {
   
        Message({
   
          message: "评论不能为空",
          type: "warning",
          duration: 5 * 1000
        });
      } else if (this.lpdptel == "") {
   
        this.islpdp = true;
        //this.tiptan(4);
      }
    },
   
 //1.验证手机号 正则判断为正确的手机号才发送验证请求;
    codetap () {
   
      if (!/^1[34578]\d{9}$/.test(this.lpdptel)) {
   
        Message({
   
          message: "请填写正确的手机号",
          type: "warning",
          duration: 5 * 1000
        });
      } else {
   
        const params = {
   
          mobile: this.lpdptel
        };
        sendCode(params).then(res => {
   
          console.log(res);
          if (res.msg == "发送成功!") {
   
            Message({
   
              message: "发送成功!",
              type: "warning",
              duration: 5 * 1000
            });
          }
        });
      }
    },

//3.最后提交评论 判断手机号正确 验证码不为空 提交评论;
    getloupanpinglun () {
   
      if (this.ison) {
   
        if (!/^1[34578]\d{9}$/.test(this.lpdptel)) {
   
          Message({
   
            message: "请填写正确的手机号",
            type: "warning",
            duration: 5 * 1000
          });
        } else if (this.code == "") {
   
          Message({
   
            message: "请填写验证码",
            type: "warning"
  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值