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

  1.  
    <div>
  2.  
    <p class="fl">
  3.  
    <input name="phone" type="number" placeholder="手机号" v-model="phone"/>
  4.  
    <button type="button" :disabled="disabled" @click="sendcode" class="btns">{{btntxt}}</button>
  5.  
    </p>
  6.  
    <p class="fl" style="margin-left: 20px;">
  7.  
    <input type="text" placeholder="验证码"/>
  8.  
    </p>
  9.  
    </div>
  10.  
    <input type="button" value="查询" class="btns search" @click="query"/>

这里是script里的内容

  1.  
    export default {
  2.  
    data: function () {
  3.  
    return {
  4.  
    disabled:false,
  5.  
    time:0,
  6.  
    btntxt:"获取验证码",
  7.  
    formMess:{
  8.  
    email:this.email,
  9.  
    phone:this.phone
  10.  
    }
  11.  
    }
  12.  
    },
  13.  
    mounted: function () {
  14.  
     
  15.  
    },
  16.  
    methods:{
  17.  
    //验证手机号码部分
  18.  
    sendcode(){
  19.  
    var reg=11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
  20.  
    //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
  21.  
    if(this.phone==''){
  22.  
    alert("请输入手机号码");
  23.  
    }else if(!reg.test(this.phone)){
  24.  
    alert("手机格式不正确");
  25.  
    }else{
  26.  
    this.time=60;
  27.  
    this.disabled=true;
  28.  
    this.timer();
  29.  
    /*axios.post(url).then(
  30.  
    res=>{
  31.  
    this.phonedata=res.data;
  32.  
    })*/
  33.  
    }
  34.  
    },
  35.  
    timer() {
  36.  
    if (this.time > 0) {
  37.  
    this.time--;
  38.  
    this.btntxt=this.time+"s后重新获取";
  39.  
    setTimeout(this.timer, 1000);
  40.  
    } else{
  41.  
    this.time=0;
  42.  
    this.btntxt="获取验证码";
  43.  
    this.disabled=false;
  44.  
    }
  45.  
    },
  46.  
    query(){
  47.  
    var formMess=this.formMess
  48.  
    Axios.post(api+"/order/select/reception", formMess)
  49.  
    .then(function (res) {
  50.  
    if(res.data.code==200){
  51.  
    console.log(res.data.data);
  52.  
    this.productResult=res.data.data;
  53.  
    this.productResult.length=3;
  54.  
    }else if(res.data.code==400){
  55.  
    alert(res.data.message)
  56.  
    }
  57.  
     
  58.  
    }.bind(this))
  59.  
    },
  60.  
    //邮箱验证
  61.  
    sendEmail(){
  62.  
    var regEmail= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  63.  
    if(this.email==''){
  64.  
    alert("请输入邮箱");
  65.  
    }else if(!regEmail.test(this.email)){
  66.  
    alert("邮箱格式不正确");
  67.  
    }
  68.  
    }
  69.  
    }
  70.  
    }
 

vue中手机号,邮箱正则验证以及60s发送验证码的更多相关文章

  1. vue中的表单验证

    http://www.cnblogs.com/luoxuemei/p/9295506.html /*是否合法IP地址*/ export function validateIP(rule, value, ...

  2. winform 学习之qq邮箱正则验证及常用正则

    这段时间一直再做winform相关的项目,记录了一些东西 qq邮箱正则表达式: 第一种:字母和数字组合邮箱判断 string str = "justin1107@qq.com"; ...

  3. php email邮箱正则验证

    国际域名格式如下: 域名由各国文字的特定字符集.英文字母.数字及“-”(即连字符或减号)任意组合而成, 但开头及结尾均不能含有“-”,“-”不能连续出现 . 域名中字母不分大小写.域名最长可达60个字 ...

  4. Vue中Form表单验证无法消除验证问题

    iView的表单api给出了一个resetFields方法,用于重置整个表单输入的内容并清除验证提示. 但是有时候需要只消除部分的iview的resetFields方法源码是这样的resetField ...

  5. java邮箱正则验证

    import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class tes ...

  6. 邮箱、手机号、中文 js跟php正则验证

    邮箱正则: jS: var regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; //验证 if(regEmail.te ...

  7. ASP.NET中 RegularExpressValidator(正则验证)的使用

    原文:ASP.NET中 RegularExpressValidator(正则验证)的使用 ylbtech-ASP.NET-Control-Validator: RegularExpressValida ...

  8. 在js中实现邮箱格式的验证

    在js中实现邮箱格式的验证 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><htm ...

  9. JavaScript正则验证邮箱

    正则表达式/^正则$/.test() <html> <head> <title>JavaScript</title> <meta charset= ...

随机推荐

  1. 洛谷 [P3834] 可持久化线段树(主席树)

    主席树可以存储线段树的历史状态,空间消耗很大,一般开45n即可 #include <iostream> #include <cstdio> #include <cstri ...

  2. openSUSE Leap 15.0 初始配置

    添加源: # 禁用原有软件源 sudo zypper mr -da # 添加阿里镜像源 sudo zypper ar -fc https://mirrors.aliyun.com/opensuse/d ...

  3. eopkg命令

    #命令: add-repo (ar)  ---添加存储库 blame (bl)  ---包所有者和发布信息 build (bi)  ---建立eopkg包 check  ---验证安装 clean  ...

  4. Oracle 12c PDB和CDB全局用户权限问题

    Oracle12c版本中引入了新的CDB和PDB 默认登陆CDB后创建的用户为全局用户必须以c##开头 如果要访问CDB中的表,可以用GRANT命令赋权 但是上面的赋权并不会再PDB中生效 如果要这个 ...

  5. T1063 合并果子 codevs

    http://codevs.cn/problem/1063/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond   题目描述 Description 在一个 ...

  6. Windows下配置scrapy需要MVC的14.0版本(转载)

    转载于--http://blog.csdn.net/MrWilliamVs/article/details/77130965 杨煜冬煜杨的博客,他的博客比较杂,Java.Python都有--http: ...

  7. Python资料大全

    说明:以下文章为转载,有英文原文和中文整理翻译,对原作者和译者的工作表示极大感谢!!! 英文原文:https://github.com/vinta/awesome-python 中文译文:https: ...

  8. Setup and Teardown Thread Group in Jmeter

    setup和teardown有点类似于每个测试用例开始和结束时要做的动作 A Thread Group is the starting point of any Jmeter Test Plan. A ...

  9. android官方Api 理解Activity生命周期的回调机制(适合有基础的人看)

    原文地址:http://www.android-doc.com/training/basics/activity-lifecycle/starting.html#lifecycle-states 此处 ...

  10. [Binary Hacking] ABI and EABI

    Following are some general papers about ABI and EABI. Entrance https://en.wikipedia.org/wiki/Applica ...