第一种,身份证号 校验,并且 年月日 显示 **** 代替

<div class="list"><div>身份证号</div><input placeholder="请输入身份证号" type="text" v-model="idNumber" @blur="idNumberFun"/></div>
idNumberFun(){var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;  if(reg.test(this.idNumber) === false){  this.$toast('请输入正确的身份证号');return  false;} this.requstIdNumber = this.idNumberthis.idNumber =    this.changeIdCardIncludeStart(this.idNumber)console.log(this.idNumber,'-===',this.requstIdNumber)},changeIdCardIncludeStart (cardId) {const newStr = cardId.replace(/^(.{6})(?:\d+)(.{4})$/,"$1****$2");return newStr;},

第二种, 配合 vant 的 身份证键盘

<div class="cardbox" @click="open"><span>{{card1}}</span><span>{{card2}}</span><span>{{card3}}</span><span>{{card4}}</span><span>{{card5}}</span><span>{{card6}}</span><span>{{card7}}</span><span>{{card8}}</span><span>{{card9}}</span><span>{{card10}}</span><span class="xingbox">*</span><span class="xingbox">*</span><span class="xingbox">*</span><span class="xingbox">*</span><span>{{card15}}</span><span>{{card16}}</span><span>{{card17}}</span><span>{{card18}}</span>
</div><van-number-keyboardv-model="value"extra-key="X"close-button-text="完成":show="showKeyboard"@blur="closekeyboard"@close="closekeyboard"
/>
 data() {return {value: '', // watch 监听 实时输入的 数字showKeyboard: false, // 键盘是否弹起cardarr:[], // 存放 输入的数字 数组card1:'',card2:'',card3:'',card4:'',card5:'',card6:'',card7:'',card8:'',card9:'',card10:'',card15:'',card16:'',card17:'',card18:'',xing:'*'}
}
 watch: {value(value) {// 字符串 转 数组 类似于 123 转 【1,2,3】this.cardarr = [ ...value ]// 因为中间 四位转**** 代替,所以,一共输入的是14位数字if(this.cardarr.length > 14){this.cardarr = this.cardarr.splice(0,14);this.value = this.value.substring(0,14);}this.card1 = this.cardarr[0]this.card2 = this.cardarr[1]this.card3 = this.cardarr[2]this.card4 = this.cardarr[3]this.card5 = this.cardarr[4]this.card6 = this.cardarr[5]this.card7 = this.cardarr[6]this.card8 = this.cardarr[7]this.card9 = this.cardarr[8]this.card10 = this.cardarr[9]this.card15 = this.cardarr[10]this.card16 = this.cardarr[11]this.card17 = this.cardarr[12]this.card18 = this.cardarr[13]},
},
// 打开键盘
methods:{open(){this.showKeyboard = truethis.cardarr = []this.value = ''this.card1 = ''this.card2 = ''this.card3 = ''this.card4 = ''this.card5 = ''this.card6 = ''this.card7 = ''this.card8 = ''this.card9 = ''this.card10 = ''this.card15 = ''this.card16 = ''this.card17 = ''this.card18 = ''},// 关闭键盘closekeyboard(){this.showKeyboard = falseif(this.cardarr.length < 14){this.$toast('请输入正确的身份证号');return  false;}this.idNumber = this.valuethis.requstIdNumber = this.idNumber// 身份证号 拼接成这样  4108820000****1222this.requstIdNumber = this.requstIdNumber.slice(0,10) + "****" + this.requstIdNumber.slice(10,14)},
}

【input 身份证号】星号 代替,input 切割成 多个 小格格(类似)相关推荐

  1. 使用mysql将姓名、手机号、身份证号等敏感字段替换成*号

    -- 脱敏 姓名 UPDATE art_user SET nick_name = IF(LENGTH(nick_name) > 6, CONCAT(LEFT(nick_name, 1), '** ...

  2. Vue中根据输入的身份证号识别年龄、性别

    需求: 根据用户输入的身份证号识别出年龄和性别,回显到相应的输入框中 分析:定义身份证号的正则表达式,利用字符串的方法截取出相关字符进行判断 示例: <template> <div ...

  3. 微信小程序:校验真实姓名和身份证号

    1.界面 2. 代码 login.wxml <view wx:if="{{role}}"><view class="box"><v ...

  4. javascript实现根据身份证号读取相关信息

    本文转载:https://www.jb51.net/article/58643.htm 这篇文章主要介绍了javascript实现根据身份证号读取相关信息,需要的朋友可以参考下 公民身份号码由六位数字 ...

  5. 正则表达式验证手机号、身份证号

    正则验证手机号,中文,身份证号 var certNo=$("input[name=Idcard]").val(); //身份证号var sfreg1 = /(^\d{15}$)|( ...

  6. 火车票身份证号打码真的安全吗

    火车票身份证号4位打码安全吗? 科普居民身份证号的生成和计算方式. 如果看上面这个太抽象,那么如下方式让你明白 身份证号码作为独一无二代表公民信息的号码,它的组成是由一下的数字表示的: (1)第1.2 ...

  7. python 根据身份证号计算年龄和性别_excel如何根据身份证号计算男女出生日期、性别和年龄?分享了!...

    工作中,有时需要从身份证号中提取性别.出生日期.年龄等.如果手工统计,不仅容易出错,还耗时耗力.春暖花开的时候,有那时间不如出去踏青散步,赏花游玩. 下面小编为大家分享一种方法,使用Excel函数轻松 ...

  8. input输入身份证号 实现自动生成个人信息

    input输入身份证号 实现自动生成个人信息 <el-form-item label="身份证号:" prop="identityCard">< ...

  9. wps姓名隐藏为星号_EXCEL里如何给姓名手机号身份证号等隐私信息设置星号隐藏起来?...

    在EXCEL表格里如图有时为了保护隐私,需要把姓名啊手机啊身份证号啊这些敏感的个人信息以星号显示,要如何操作呢?下面演示一下操作步骤: 一.星号姓名 1.在需要设置的单元格里输入=REPLACE(E2 ...

最新文章

  1. postgresql学习笔记(三)连接管理
  2. 阿里双十一秒杀系统架构设计,有哪些技术关键点?
  3. C++设计模式之代理模式
  4. Source Insight上手教程
  5. 将标签重新定义为4个空格
  6. Cesium:加载本地高程/地形数据
  7. otool nm工具命令收集
  8. 学习微信开发公众号的第一天(根据文字自动回复文字)
  9. 蓝桥杯算法训练VIP-调和数列问题
  10. html设置首缩选进两字符,首行缩进2字符怎么设置 css
  11. Show出你的高超技能 首届“中国高性能云计算创新大赛”要开赛啦!
  12. git 删除git管理_使用Git管理多媒体文件
  13. 分区失败,在计算机中不能打开磁盘,但是在磁盘管理软件中能打开的解决方法
  14. MAX-SUM算法信息传递规则的优化
  15. 基于Swing的Java学生成绩管理系统
  16. weblogic修改密码
  17. MYSQL数据库----删除命令
  18. win10硬盘启动从IDE改成ahci后无法启动系统的解决方式
  19. PHP读取纯真IP地址数据库
  20. 导入excel到mysql

热门文章

  1. 汉字转拼音 java_Java汉字转拼音工具类完整代码实例
  2. 程序设计基础c语言邹启明,【基础强化】2020年秋季学期程序设计C语言项目顺利结课...
  3. NISP一级模拟题(一、二)
  4. docker 存储驱动之overlay2
  5. Reog Ponorogo是爪哇族人在印尼的一个部落的传统舞蹈
  6. 这就是裸金属服务器?
  7. 历数国内外知名制作人~~制作人发展趋势
  8. python发送短信验证码_python发送短信验证码
  9. a360desktop有用吗_A360 Desktop 停用 - 2018 年 6 月 19 日
  10. 伽罗华域(Galois Field)理解、基于伽罗华域的四则运算(附详细python代码)