身份證驗證 涉及到每一位數的驗證以及後四位需要計算,所以一般的正則無法滿足
checkidcard(num) $)|(^\d([0-9]|x)$)/.test(num)))
//校驗位按照iso 7064:1983.mod 11-2的規定生成,x可以認為是數字10。
//下面分別分析出生日期和校驗位
var len, re;
len = num.length;
if (len == 15) )(\d)(\d)(\d)(\d)$/);
var arrsplit = num.match(re);
//檢查生日日期是否正確
var dtmbirth = new date('19' + arrsplit[2] + '/' + arrsplit[3] + '/' + arrsplit[4]);
var bcorrectday;
bcorrectday = (dtmbirth.getyear() == number(arrsplit[2])) && ((dtmbirth.getmonth() + 1) == number(arrsplit[3])) &&
(dtmbirth.getdate() == number(arrsplit[4]));
if (!bcorrectday) else
num += arrch[ntemp % 11];
return true;}}
if (len == 18) )(\d)(\d)(\d)(\d)([0-9]|x)$/);
var arrsplit = num.match(re);
//檢查生日日期是否正確
var dtmbirth = new date(arrsplit[2] + "/" + arrsplit[3] + "/" + arrsplit[4]);
var bcorrectday;
bcorrectday = (dtmbirth.getfullyear() == number(arrsplit[2])) && ((dtmbirth.getmonth() + 1) == number(arrsplit[3])) &&
(dtmbirth.getdate() == number(arrsplit[4]));
if (!bcorrectday) else
valnum = arrch[ntemp % 11];
if (valnum != num.substr(17, 1))
return true;}}
return false;
}
身份證驗證JS
function checkidcardstrict idcard var idcard idcard.touppercase var y,jym var s,m var idcard array new array element val idcard idcard array idcard.sp...
js 身份證驗證
function checkidcard idcard var idcard,y,jym var s,m var idcard array new array idcard array idcard.split 地區檢驗 if area parseint idcard.substr 0,2 null...
身份證驗證
1 簡單的正規表示式 1 preg match d d dx id card 2 preg match d 18 19 20 d 01 d 0123 d d d x id card 3 preg match d d d x x id card 2 複雜並且嚴格一些的驗證 這個可以驗證15位和18位的...