<%@ webservice language="c#" class="weatherws.checkcid" %>
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.diagnostics;
using system.web;
using system.web.services;
namespace weatherws
#region 元件設計器生成的**
//web 服務設計器所必需的
private icontainer components = null;
///
/// 設計器支援所需的方法 - 不要使用**編輯器修改
/// 此方法的內容。
///
private void initializecomponent()
///
/// 清理所有正在使用的資源。
///
protected override void dispose( bool disposing )
base.dispose(disposing);
} #endregion
[webmethod(description="輸入15或18位身份證號碼以驗證其有效性")]
public iddataclass checkcidinfo(string cid)
; double isum=0;
iddataclass _ciddata = new iddataclass();
system.text.regularexpressions.regex rg = new system.text.regularexpressions.regex(@"^/d(/d|x)$|^/d$");
system.text.regularexpressions.match mc = rg.match(cid);
if(!mc.success)
if(cid.length==15) cid = this.convert15to18(cid);
cid = cid.tolower();
cid = cid.replace("x","a");
if(acity[int.parse(cid.substring(0,2))]==null)
try
catch
for(int i=17;i>=0;i--)
if(isum%11!=1)
_ciddata.isvalid = true;
_ciddata.chkinfo = 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?"男":"女");
return _ciddata;
} //將15位身份證號碼轉換為18位
private string convert15to18(string cid)
; int intquan = ;
string strtemp;
int inttemp = 0;
strtemp = cid.substring(0,6) + "19" + cid.substring(6);
for (int i=0;i<=strtemp.length-1;i++)
inttemp = inttemp % 11;
return strtemp + strjiaoyan[inttemp];
} }
//用於儲存身份證驗證結果的類
public class iddataclass
public bool isvalid;
public string chkinfo;
} }
作者blog:http://blog.csdn.net/lingfeng0626/
身份證號碼驗證
說明 驗證身份證的有效性 引數 cid 身份證號碼 返回 地方 出生時間 性別 private string checkcidinfo string cid if cid.length 18 char c cid cid.length 1 bool last false if c 0 c 9 c a...
驗證身份證號碼
好久沒更新了,今天簽到啦。感覺這個驗證挺重要的,也挺常用的,所以分享給需要的朋友。驗證身份證號碼,在網上找到的好東東 function checkidcard idcard var idcard,y,jym var s,m var idcard array new array idcard arra...
驗證身份證號碼
var idcardnoutil powers 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 paritybit 1 0 x 9 8 7 6 5 4 3 2 genders checkaddresscode function addresscode test address...
身份證號碼
每一個人自出生後都會有一個身份證號碼。根據我國有關部門規定,公民身份號碼是特徵組合碼,由十七位數字本體碼和一位數字校驗碼組成。排列順序從左至右依次為 六位數字地址碼,八位數字出生日期碼,三位數字順序碼和一位數字校驗碼。居民身份證是國家法定的證明公民個人身份的有效證件。例如 對於身份證號碼330719...
身份證號碼驗證演算法
title 身份證號碼驗證演算法 date 2016 06 26 16 36 41 categories 演算法 tags 演算法 經常會見到一些鑑別身份證號碼是否真實的辨別,根據網上的身份證號碼驗證演算法,做以總結。公民身份證號碼是特徵組合碼,由十七位數字和一位校驗碼組成。表示編碼物件常住戶口所在...