原文:
做乙個牛xx的身份證號驗證類(支援15位和18位)
#region 是否合法的中國身份證號碼
protected bool ischineseid()
else
return false;
}#endregion
#region 中國身份證號碼驗證
private string checkcidinfo(string cid)
;double isum = 0;
string info = string.empty;
system.text.regularexpressions.regex rg = new system.text.regularexpressions.regex(@"^\d(\d|x)$");
system.text.regularexpressions.match mc = rg.match(cid);
if (!mc.success)
return string.empty;
cid = cid.tolower();
cid = cid.replace("x", "a");
if (acity[int.parse(cid.substring(0, 2))] == null)
return "非法地區";
trycatch
for (int i = 17; i >= 0; i--)
isum += (system.math.pow(2, i) % 11) * int.parse(cid[17 - i].tostring(), system.globalization.numberstyles.hexnumber);
if (isum % 11 != 1)
return ("非法證號");
else
return (acity[int.parse(cid.substring(0, 2))] + "," + cid.substring(6, 4) + "-" + cid.substring(10, 2) + "-" + cid.substring(12, 2) + "," + (int.parse(cid.substring(16, 1)) % 2 == 1 ? "男" : "女"));
}#endregion
#region 身份證號碼15公升級為18位
private string cidupdate(string shortcid)
;int intquan = ;
string strtemp;
int inttemp = 0;
strtemp = shortcid.substring(0, 6) + "19" + shortcid.substring(6);
for (int i = 0; i <= strtemp.length - 1; i++)
inttemp = inttemp % 11;
return strtemp + strjiaoyan[inttemp];
}#endregion
身份證號的驗證處理
問題1 如何判斷身份證號 正規表示式為 d d d d x x layui框架的表單驗證,框內需要保持一致。問題2 輸入的身份證號如果有x,輸入小寫,自動轉為大寫 css有乙個屬性text transform 給input繫結乙個class,新增樣式 輸入小寫x,自動轉為大寫,效果如圖 問題3 登陸...
乙個提取身份證號生日的函式
function sfzztobdayy ss string string var i,j integer f string aa string begin f case length ss of 15 begin i 7 j 12 while i j do begin aa aa copy ss,...
推薦人身份證號的驗證
1,游標切換時,要校驗推薦人身份證格式 2,根據該身份證號查詢對應的account表中的id,並將id記錄到頁面的hidden中,表單提交時,將此hidden資料提交給推薦人id欄位。3 dao action struts.xml jsp dao public account findbyidcar...