export function isIDCardNumber( idNum: string): boolean{

if ( idNum. length != 15 && idNum. length != 18) {

return false;

}

// 15位规则

let fifteen = / ^ [ 1-9 ] \d {5} \d {2} (( 0 [ 1-9 ]) | ( 10 | 11 | 12 ))(([ 0-2 ][ 1-9 ]) | 10 | 20 | 30 | 31 ) \d {2} $ /;

// 18位规则

let eighteen = / ^ [ 1-9 ] \d {5} ( 18 | 19 | ([ 23 ] \d )) \d {2} (( 0 [ 1-9 ]) | ( 10 | 11 | 12 ))(([ 0-2 ][ 1-9 ]) | 10 | 20 | 30 | 31 ) \d {3} [ 0-9Xx ] $ /;

// 15正则匹配

let isFifteen = fifteen. test( idNum);

// 18位正则匹配

let isEighteen = eighteen. test( idNum);

if( isFifteen || isEighteen){

return true;

}

return false ;

}