我们都知道身份证号码长度是18位,要么是18位全是数字,要么17位是数字,最后一位是X
/**
* 身份证验证
* @param idStr
* @return
*/
public static boolean IdentityCardVerification(String idStr){
boolean verification =false;
String[] wf = {"1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2" ,"X"};
String iDCardNo ="";
//判断号码的长度18位
if (idStr.length() !=18) {
return verification;
}
if (idStr.length() ==18) {
iDCardNo = idStr.substring(0, 17);
}
if (isStrNum(iDCardNo) ==false) {
return verification;
}
for(int i=0;i< wf.length;i++){
if(idStr.substring(17,18).equals(wf[i])){
verification =true;
return verification;
}else{
verification =false;
}
}
return verification;
}