加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vue中手机号,邮箱正则验证以及60s发送验证码的实例

发布时间:2020-12-17 02:30:22 所属栏目:百科 来源:网络整理
导读:今天写了一个简单的验证,本来前面用的组件,但是感觉写的组件在此项目不是很好用,由于用到的地方比较少,所以直接写在了页面中。 这里是script里的内容 },methods:{ //验证手机号码部分 sendcode(){ var reg=11 /^((13|14|15|17|18)[0-9]{1}d{8})$/; //va

今天写了一个简单的验证,本来前面用的组件,但是感觉写的组件在此项目不是很好用,由于用到的地方比较少,所以直接写在了页面中。

这里是script里的内容

},methods:{
//验证手机号码部分
sendcode(){
var reg=11 && /^((13|14|15|17|18)[0-9]{1}d{8})$/;
//var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
if(this.phone==''){
alert("请输入手机号码");
}else if(!reg.test(this.phone)){
alert("手机格式不正确");
}else{
this.time=60;
this.disabled=true;
this.timer();
/axios.post(url).then(
res=>{
this.phonedata=res.data;
})
/
}
},timer() {
if (this.time > 0) {
this.time--;
this.btntxt=this.time+"s后重新获取";
setTimeout(this.timer,1000);
} else{
this.time=0;
this.btntxt="获取验证码";
this.disabled=false;
}
},query(){
var formMess=this.formMess
Axios.post(api+"/order/select/reception",formMess)
.then(function (res) {
if(res.data.code==200){
console.log(res.data.data);
this.productResult=res.data.data;
this.productResult.length=3;
}else if(res.data.code==400){
alert(res.data.message)
}

 }.bind(this))

},//邮箱验证
sendEmail(){
var regEmail= /^([a-zA-Z0-9]+[|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/;
if(this.email==''){
alert("请输入邮箱");
}else if(!regEmail.test(this.email)){
alert("邮箱格式不正确");
}
}
}
}

以上这篇vue中手机号,邮箱正则验证以及60s发送验证码的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读