進入認證頁面準備:
判斷電話號碼是否可用&點亮獲取短信按鈕:
手機認證:
實名認證:
驗證身份證:
//驗證身份證
function AuthIDcard(idCard){
var Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];
var ValideCode = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ];
function isTrueValidateCodeBy18IdCard(a_idCard) {
var sum = 0;
if (a_idCard[17].toLowerCase() == 'x') {
a_idCard[17] = 10;
}
for ( var i = 0; i < 17; i++) {
sum += Wi[i] * a_idCard[i];
}
var valCodePosition = sum % 11;
if (a_idCard[17] == ValideCode[valCodePosition]) {
return true;
} else {
return false;
}
}
function isValidityBrithBy18IdCard(idCard18){
var year = idCard18.substring(6,10);
var month = idCard18.substring(10,12);
var day = idCard18.substring(12,14);
var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));
if(temp_date.getFullYear()!=parseFloat(year)
||temp_date.getMonth()!=parseFloat(month)-1
||temp_date.getDate()!=parseFloat(day)){
return false;
}else{
return true;
}
}
function isValidityBrithBy15IdCard(idCard15){
var year = idCard15.substring(6,8);
var month = idCard15.substring(8,10);
var day = idCard15.substring(10,12);
var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));
if(temp_date.getYear()!=parseFloat(year)
||temp_date.getMonth()!=parseFloat(month)-1
||temp_date.getDate()!=parseFloat(day)){
return false;
}else{
return true;
}
}
function trim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
idCard = trim(idCard.replace(/ /g, ""));
if (idCard.length == 15) {
return isValidityBrithBy15IdCard(idCard);
} else if (idCard.length == 18) {
var a_idCard = idCard.split("");
if(isValidityBrithBy18IdCard(idCard)&&isTrueValidateCodeBy18IdCard(a_idCard)){
return true;
}else {
return false;
}
} else {
return false;
}
}
郵箱驗證: