js根据身份证号取日期和性别
//card是身份证 sr是生日 function cardData(){ var card = $("#cardNumber").val();//身份证号 var sr = $("#birthday").val(); var cE = /^\d{6}((?:19|20)(?:(?:\d{2}(?:0[13578]|1[02])(?:0[1-9]|[12]\d|3[01]))|(?:\d{2}(?:0[13456789]|1[012])(?:0[1-9]|[12]\d|30))|(?:\d{2}02(?:0[1-9]|1\d|2[0-8]))|(?:(?:0[48]|[2468][048]|[13579][26])0229)))\d{2}(\d)[xX\d]$/; if(card.length>0 && cE.test(card)){//身份证 if(sr.length<1){//生日没值 var t = RegExp.$1; var y=t.substr(0,4); var m =t.substr(4,2); var d = t.substr(6,4); $("#birthday").val(y+"-"+m+"-"+m); } } }
?