// -- ID card number verification-new x ID card supported
Function isIdCardNo (num)
{
Var factorArr = new Array );
Var error;
Var varArray = new Array ();
Var intValue;
Var lngProduct = 0;
Var intCheckDigit;
Var intStrLen = num. length;
Var idNumber = num;
// Initialize
If (intStrLen! = 15) & (intStrLen! = 18 )){
// Error = "the length of the ID card number entered is incorrect! ";
// Alert (error );
// FrmAddUser.txt IDCard. focus ();
Return false;
}
// Check and set value
For (I = 0; I <intStrLen; I ++ ){
VarArray [I] = idNumber. charAt (I );
If (varArray [I] <'0' | varArray [I]> '9') & (I! = 17 )){
// Error = "Incorrect ID number !. ";
// Alert (error );
// FrmAddUser.txt IDCard. focus ();
Return false;
} Else if (I <17 ){
VarArray [I] = varArray [I] * factorArr [I];
}
}
If (intStrLen = 18 ){
// Check date
Var date8 = idNumber. substring (6, 14 );
If (checkDate (date8) = false ){
// Error = "incorrect date information in ID card !. ";
// Alert (error );
Return false;
}
// Calculate the sum of the products
For (I = 0; I <17; I ++ ){
LngProduct = lngProduct + varArray [I];
}
// Calculate the check digit
IntCheckDigit = 12-lngProduct % 11;
Switch (intCheckDigit ){
Case 10:
IntCheckDigit = 'X ';
Break;
Case 11:
IntCheckDigit = 0;
Break;
Case 12:
IntCheckDigit = 1;
Break;
}
// Check last digit
If (varArray [17]. toUpperCase ()! = IntCheckDigit ){
// Error = "Incorrect ID card verification space !... Correct: "+ intCheckDigit + ".";
// Alert (error );
Return false;
}
}
Else {// length is 15
// Check date
Var date6 = idNumber. substring (6, 12 );
If (checkDate (date6) = false ){
// Alert ("the date of the ID card is incorrect !. ");
Return false;
}
}
// Alert ("Correct .");
Return true;
}
From the column by Liu haicao