微信小程序> 微信小程序正则验证手机号、邮箱及错误提示

微信小程序正则验证手机号、邮箱及错误提示

浏览量:533 时间: 来源:初心-杨瑞超个人博客

初心-杨瑞超个人博客诚邀您加入qq群(IT-程序猿-技术交流群): 757345416丨(IT-程序猿-技术交流2群): 936929828

直接贴代码了:

telBlur: function (e) {    const { tel } = this.data;    const telReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(16[0-9]{1})|(17[0-9]{1}))+d{8})$/;    if (!tel) {      wx.showToast({        title: '手机号不能为空',        icon: 'none',        duration: 2000      })    } else if (!telReg.test(tel)) {      wx.showToast({        title: '请输入正确的手机号',        icon: 'none',        duration: 2000      })    }  },emailBlur: function (e) {    const { email } = this.data;    const emailReg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,4}$/;     if (!email) {      wx.showToast({        title: '邮箱不能为空',        icon: 'none',        duration: 2000      })    } else if (!emailReg.test(email)) {      wx.showToast({        title: '请输入正确的邮箱',        icon: 'none',        duration: 2000      })    }  },

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎