在标签上可以直接进行校验如下,如果只调数字键盘type=number不好用可以用type=tel
<input name="creditDate" oninput="value = value.replace(/[^\d{2}\/{1}\d{2}$]/ig,'')"   @keyup="changeVal"   v-model="getDate" type="text" placeholder="月/年">

changeVal(e){
let $val = e.currentTarget.value;
e.currentTarget.value = $val.replace(/[^\d{2}\/{1}\d{2}$]/ig,'')
let inputVal = e.currentTarget.value
this.all = true;
if(/^[2-9]/ig.test(inputVal)){
e.currentTarget.value = '0'+inputVal
this.all1 = true;
}
if(/^[1]/ig.test(inputVal)){
e.currentTarget.value = e.currentTarget.value.replace(/^1[^0-2|/]/ig,'1')
this.all1 = true;
}
if(/^[0]/ig.test(inputVal)){
e.currentTarget.value = e.currentTarget.value.replace(/^0[^1-9|/]/ig,'0')
this.all1 = true;
}
if(e.currentTarget.value.length == 2 && e.keyCode !=8 && !/^1\//ig.test(e.currentTarget.value)){
e.currentTarget.value = e.currentTarget.value + '/'
this.all2 = true;
}
if(e.currentTarget.value.length >= 5){
e.currentTarget.value = e.currentTarget.value.substr(0,5)
this.all3 = true;
}
e.currentTarget.value = e.currentTarget.value.replace(/[^\d{2}\/{1}\d{2}$]/ig,'')
this.getDate = e.currentTarget.value
if(this.all && this.all1 && this.all2 && this.all3){
this.submitBtnFrag();
}
}

宜人贷项目里-----正则匹配input输入月份规则的更多相关文章

  1. js正则匹配只能输入有效数字可加小数点

    var reg = /^\d+\.?\d*$/; if(value.search(/^\d+\.?\d*$/)===0 && parseFloat(value)>0){//只能输 ...

  2. 正则验证input输入,要求只能输入正数,小数点后保留两位。

    <input type="number" step="1" min="0" onkeyup="this.value= thi ...

  3. php中文正则匹配

    今天接到一个需求,用户昵称系统需要将昵称输入的字符类型限定为 中文,英文,数字, -,_ 显然这个应该用正则来实现,那么最终的规则是怎么样的呢?示例代码如下: <?php $str = '我爱北 ...

  4. 正则匹配抓取input 隐藏输入项和 <td>标签内的内容

    这里不多作解释了,只要提供方法,如果想了解正则匹配,就去百度. 第一条是,匹配出所有的隐藏输入域 $patern = "/<input(.*?)type=\"hidden\& ...

  5. JS通过正则限制 input 输入框只能输入整数、小数(金额或者现金)

    第一: 限制只能是整数 <input type = "text" name= "number" id = 'number' onkeyup= " ...

  6. 使用JS通过正则限制input的输入

    第一: 限制只能是整数 type = "text" name= "number" id = 'number' onkeyup= "if(! /^d+$ ...

  7. 正则表达式控制Input输入内容 ,js正则验证方法大全

    https://blog.csdn.net/xushichang/article/details/4041507 //输入姓名的正则校验 e.currentTarget.value = e.curre ...

  8. JavaScript 正则匹配中文,中文符号,空格,全数字,以https:// 开头的url,用于各种场景的输入校验

    业务场景1: 密码输入框需要验证输入中文,中文符号,空格等情况,以便于给出错误提示 业务场景2: 输入框只允许输入数字的情况 业务场景3: 输入框允许输入均为数字或以https:// 开头的url的情 ...

  9. python_way day18 html-day4, Django路由,(正则匹配页码,包含自开发分页功能), 模板, Model(jDango-ORM) : SQLite,数据库时间字段插入的方法

    python_way day18 html-day4 1.Django-路由系统   - 自开发分页功能 2.模板语言:之母板的使用 3.SQLite:model(jDango-ORM) 数据库时间字 ...

随机推荐

  1. Git & TortoiseGit

    http://www.git-scm.com/download/ http://download.tortoisegit.org/ https://help.github.com/articles/g ...

  2. review一个javascript功能函数

    近半年来一直觉得自己在技术上好像左右挣扎,技术没啥提升,看书看不进,自学还挺慢.写出来的东西,自己都觉得不满意.让自己也用庸人自扰的感觉. 最近,在工作中,有一个小小的功能需要实现,这个功能非常简单, ...

  3. Android 内存优化[转]

    一. Android的内存机制 Android的程序由Java语言编写,所以Android的内存管理与Java的内存管理相似.程序员通过new为对象分配内存,所有对象在java堆内分配空间:然而对象的 ...

  4. JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(11):XML和Annotation装配Bean的混合使用(@ImportResource)

    一.XML和Annotation装配Bean如何合理使用 引入第三方资源包中类的时候,建议使用XML配置,而使用自己编写的Java类的时候,推荐使用Annotation注解配置Bean. 二.关于注解 ...

  5. 编写高质量代码改善C#程序的157个建议——建议80:用Task代替ThreadPool

    建议80:用Task代替ThreadPool ThreadPool相对于Thread来说具有很多优势,但是ThreadPool在使用上却存在一定的不方便.比如: ThreadPool不支持线程的取消. ...

  6. Finding Memory Leaks with SAP Memory Analyzer

    Introduction There is a common understanding that a single snapshot of the java heap is not enough f ...

  7. Window-document-javascript

    一个浏览器窗口有一个window对象,javascript属于window对象,html为document对象,属于window,body为document对象,只有设置body对象高度为100%,其 ...

  8. [LeetCode 题解]: Container With Most Water

    Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).  ...

  9. jquery库与其他库冲突的问题解决-jquery.noConflict()

    在使用jQuery开发的时候,可能还会使用到其他的JS库,比如Prototype,但多库共存时可能会发生冲突:若是发生冲突后,可以通过以下几种方案进行解决: 一. jQuery库在其他库之前导入,直接 ...

  10. 解决centOS 本地可以访问 外部主机不能访问的问题

    但是centos中的防火墙规则比较严密 用curl http://localhost:10000 可以看到内容,但是外部无法访问,原因是防火墙没有开启10000端口,需要将10000端口加入到信任规则 ...