求一个后台能判断填写的身份证号是否大于18岁的判断。不知道该如何做。求教大神~C#web
解决方案 »
- 数据库上传问题
- 无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Microsoft.VisualStudio.Web.Interop.I
- AJAX读取失败
- DATALIST问题
- 急...........gridview想删除一行,但不删数据库
- 请问GridView列里有TextBox,它改变了的值,怎样写到一个Hidden里去
- 在ASP.NET中按Enter从TextBox1跳到TextBox2,如何实现?急!
- 关于HTTP POST重定向方式的问题
- asp.net动态生成的TextBox如何取值?
- 如何实现asp.net发票套打
- datalist 文字不间断滚动
- 应用程序的首页指向某个文件夹下的一个文件,该文件上的图片路径错误,该如何解决
string pid = "210532298105062562";
string dateStr = pid.Substring(6, 8);
dateStr = dateStr.Substring(0, 4) + "-" + dateStr.Substring(4, 2) + "-" + dateStr.Substring(6);
DateTime birthday;
if (DateTime.TryParse(dateStr, out birthday))
{
int currentYear = DateTime.Now.Year;
int birthdayYear = birthday.Year;
int age = currentYear-birthdayYear;
if (age >= 18 && age < 150)//大于18,小于150
{
Console.WriteLine("大于18,小于150");
}
else if (age < 18 && age > 0)
{
Console.WriteLine("小于18");
}
else if (age <= 0)
{
Console.WriteLine("还没出生");
}
else
{
Console.WriteLine("已经死了");
}
}
else
{
Console.WriteLine("身份证时间格式不正确");
}
Console.ReadLine();
这样就可以读取的,
至于
身份证号不让输入,
用二代身份证阅读器,自动提取,
这个用于 winform 中
web 不好办