zoukankan      html  css  js  c++  java
  • 根据身份证自动获取年龄/出生日期

    <el-form-item label="证件号" prop="idCard">
           <el-input
                v-model="form.idCard"
                 size="small"
                 :disabled="isDisabled"
                  style="90%;"
                  @blur="getName(form.idCard)"
             ></el-input>
    </el-form-item>
    
    methods: {
          getName(iden) {
          let val = iden.length;
          let sex = null;
          let birth = null;
          let myDate = new Date();
          let month = myDate.getMonth() + 1;
          let day = myDate.getDate();
          let age = 0;
       
        //判断身份证位数为18位时去截取时间日期 if (val === 18) { age = myDate.getFullYear() - iden.substring(6, 10) - 1; sex = iden.substring(16, 17); birth = iden.substring(6, 10) + "-" + iden.substring(10, 12) + "-" + iden.substring(12, 14); if ( iden.substring(10, 12) < month || (iden.substring(10, 12) == month && iden.substring(12, 14) <= day) ) age++; }
        
        //判断身份证位数为15位时去截取时间日期 if (val === 15) { age = myDate.getFullYear() - iden.substring(6, 8) - 1901; sex = iden.substring(13, 14); birth = "19" + iden.substring(6, 8) + "-" + iden.substring(8, 10) + "-" + iden.substring(10, 12); if ( iden.substring(8, 10) < month || (iden.substring(8, 10) == month && iden.substring(10, 12) <= day) ) age++; } this.form.age = age; this.form.dob = birth; // this.getDataInfo(); } }

      

  • 相关阅读:
    MVC5+EF6 入门完整教程11--细说MVC中仓储模式的应用
    MVC5+EF6 入门完整教程十
    MVC5+EF6 入门完整教程九
    MVC5+EF6 入门完整教程八
    MVC5+EF6 入门完整教程七
    MVC5+EF6 入门完整教程六
    MVC5+EF6 入门完整教程五
    MVC5+EF6 入门完整教程四
    MVC5 + EF6 完整入门教程三
    从前端的UI开始
  • 原文地址:https://www.cnblogs.com/swmin/p/12017342.html
Copyright © 2011-2022 走看看