function Isidcardno (idvalue) {
var len=0, re;
Len=idvalue.length;
if (len = = && isnumberstring (idvalue, "1234567890"))
Re = new RegExp (/^ (D{6}) ()? ( D{2}) (D{2}) (D{2}) (D{3}) $/);
else if (len = = && isnumberstring (idvalue, "1234567890xx"))
Re = new RegExp (/^ (D{6}) ()? ( D{4}) (D{2}) (D{2}) (D{3}) (d) $/);
else {
Alert ("Enter the citizenship number is not valid, please re-enter!");
return false;
}
var a = Idvalue.match (re);
if (a!= null) {
if (len==15) {
var d = new Date ("+a[3]+"/"+a[4]+"/"+a[5]");
var B = d.getyear () ==a[3]&& (D.getmonth () +1) ==a[4]&&d.getdate () ==a[5];
}else{
var d = new Date (a[3]+ "/" +a[4]+ "/" +a[5]);
var B = d.getfullyear () ==a[3]&& (D.getmonth () +1) ==a[4]&&d.getdate () ==a[5];
}
if (!b) {
Alert ("Enter the citizenship number" + a[0] + "The date is not valid, please re-enter!");
Alert ("Enter the citizenship number is not valid, please re-enter!");
return false;
}
}
if (len = = &&!verifygmsfhlast (idvalue)) {
if (idvalue.substr (17,1) = = ' X ') {
Alert ("The last check code for the citizenship number is incorrect (' x ' should be uppercase), please check!");
}else
{
Alert ("Enter the citizenship number is not valid, please re-enter!");
}
return false;
}
return true;
}
function Verifygmsfhlast (sval) {
if (Sval.length!=) return false;
var wi = new Array (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
var vi = new Array (1,0, ' x ', 9,8,7,6,5,4,3,2)
var ai = new Array (17);
var sum = 0;
var remaining = 0;
var verifynum = "";
The first 17 bits of the 18-bit ID card are stored in the array AI by looping
for (var i = 0; i < i++) {
Ai[i] = parseint (sval.substring (i,i+1));
}
for (var m = 0; m < ai.length; m++) {
Weighted
sum = sum + wi[m] * ai[m];
}
remaining = sum% 11;
if (remaining = = 2) {
Verifynum = "X";
}else{
Verifynum = vi[remaining];
}
if (Verifynum!= sval.substring (17,18)) {
return false;
}else{
return true;
}
}