身份证号验证并获取出生日期

private void txtSFZH_Validating(object sender, CancelEventArgs e)
        {
            if (txtSFZH.Text == null || txtSFZH.Text.ToString().Trim() == "")
            {
                return;
            }
            else if (txtSFZH.Text.ToString().Length < 15)
            {
                MessageBox.Show("请输入正确的身份证号!");
                e.Cancel = true;
                return;
            }
            else
            {
                string SFZH = txtSFZH.Text;
                txtCSRQ.Text = SFZH.Substring(6, 4) + "-" + SFZH.Substring(10, 2) + "-" + SFZH.Substring(12, 2);
            }
        }

博主设置当前文章不允许评论。

没有更多推荐了,返回首页