宜人贷项目里-----正则匹配input输入月份规则
在标签上可以直接进行校验如下,如果只调数字键盘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输入月份规则的更多相关文章
- js正则匹配只能输入有效数字可加小数点
var reg = /^\d+\.?\d*$/; if(value.search(/^\d+\.?\d*$/)===0 && parseFloat(value)>0){//只能输 ...
- 正则验证input输入,要求只能输入正数,小数点后保留两位。
<input type="number" step="1" min="0" onkeyup="this.value= thi ...
- php中文正则匹配
今天接到一个需求,用户昵称系统需要将昵称输入的字符类型限定为 中文,英文,数字, -,_ 显然这个应该用正则来实现,那么最终的规则是怎么样的呢?示例代码如下: <?php $str = '我爱北 ...
- 正则匹配抓取input 隐藏输入项和 <td>标签内的内容
这里不多作解释了,只要提供方法,如果想了解正则匹配,就去百度. 第一条是,匹配出所有的隐藏输入域 $patern = "/<input(.*?)type=\"hidden\& ...
- JS通过正则限制 input 输入框只能输入整数、小数(金额或者现金)
第一: 限制只能是整数 <input type = "text" name= "number" id = 'number' onkeyup= " ...
- 使用JS通过正则限制input的输入
第一: 限制只能是整数 type = "text" name= "number" id = 'number' onkeyup= "if(! /^d+$ ...
- 正则表达式控制Input输入内容 ,js正则验证方法大全
https://blog.csdn.net/xushichang/article/details/4041507 //输入姓名的正则校验 e.currentTarget.value = e.curre ...
- JavaScript 正则匹配中文,中文符号,空格,全数字,以https:// 开头的url,用于各种场景的输入校验
业务场景1: 密码输入框需要验证输入中文,中文符号,空格等情况,以便于给出错误提示 业务场景2: 输入框只允许输入数字的情况 业务场景3: 输入框允许输入均为数字或以https:// 开头的url的情 ...
- python_way day18 html-day4, Django路由,(正则匹配页码,包含自开发分页功能), 模板, Model(jDango-ORM) : SQLite,数据库时间字段插入的方法
python_way day18 html-day4 1.Django-路由系统 - 自开发分页功能 2.模板语言:之母板的使用 3.SQLite:model(jDango-ORM) 数据库时间字 ...
随机推荐
- 关于利用word发布文章到博客
目前大部分的博客作者在写博客这件事情上都会遇到以下3个痛点:1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.2.发布到博客或公众号平台 ...
- Hortonwork Ambari配置Hive集成Hbase的java开发maven配置
集群环境 ambari 2.7.3 hdp/hortonwork 2.6.0.3 maven <dependency> <groupId>org.apache.hive< ...
- codeforces 914E Palindromes in a Tree(点分治)
You are given a tree (a connected acyclic undirected graph) of n vertices. Vertices are numbered fro ...
- 你不知道的Console
1.凡人视角 打印字符串 代码: console.log("I am a 凡人"); 打印提示消息 代码: console.info("Yes, you arm a 凡人 ...
- linux fdisk分区工具
fdisk来自IBM老牌分区工具,支持绝大多数操作系统,几乎所有的linux的发行版本都装有disk,包括linux的resure模式下的依然能够使用. fdisk是一个机遇MBR的分区工具,所有如果 ...
- Android 常用第三方框架总结
一.导航拦 1. FlycoTabLayout https://github.com/H07000223/FlycoTabLayout 2.CoordinatorTabLayout htt ...
- Android-ContentProvider读取/新增/操作系统联系人数据
想要访问Android操作系统的ContentProvider就需要明白以下原理: 在Android操作系统里面的 /packsges/目录: apps: 很多的系统应用,例如:联系人,浏览器,音乐播 ...
- mysql中判断记录是否存在方法比较【转】
把数据写入到数据库的时,常常会碰到先要检测要插入的记录是否存在,然后决定是否要写入. 我这里总结了判断记录是否存在的常用方法: sql语句:select count(*) from tablename ...
- MAVEN 编译打包时报“找不到符号”cannot find symbol 的处理方法总结
http://www.cnblogs.com/Starshot/p/7441075.html
- docker-compsoe & .netcore & nginx
1.引言 紧接上篇.NET Core容器化@Docker,这一节我们先来介绍如何使用Nginx来完成.NET Core应用的反向代理,然后再介绍多容器应用的部署问题. 2. Why Need Ngin ...