/// <summary>
/// 验证15位号码
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
private static bool CheckIDCard15(string Id)
{
long n = 0;
if (long.TryParse(Id, out n) == false || n < Math.Pow(10, 14))
{
return false;//数字验证
}
string address = "11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91";
if (address.IndexOf(Id.Remove(2)) == -1)
{
return false;//省份验证
}
string birth = Id.Substring(6, 6).Insert(4, "-").Insert(2, "-");
DateTime time = new DateTime();
if (DateTime.TryParse(birth, out time))
{
if (time.Year <= 1900 || time.Year >= 2050)
{
return false;//生日验证
}
}
else
{
return false;//生日验证
}
return true;//符合15位身份证标准
}
.Net验证15位身份证格式
于 2022-10-12 15:59:45 首次发布