输入身份证 直接获取到 年月日

`

	<input type=text v-on:oninput="getBirthday"/>

getBirthday(idCard) {  
    var birthday = "";  
    if(idCard != null && idCard != ""){  
        if(idCard.length == 15){  
            birthday = "19"+idCard.substr(6,6);  
        } else if(idCard.length == 18){  
            birthday = idCard.substr(6,8);  
        }  
        birthday = birthday.replace(/(.{4})(.{2})/,"$1-$2-");  
    }  
     this.birthday=birthday; 
  },

`

posted @ 2021-07-16 11:18  水晶草  阅读(144)  评论(0)    收藏  举报