实现效果:

使用正则表达式验证身份证号

关键知识:

 使用正则表达式验证身份证号

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            if (IsValidate(textBox1.Text.ToString()))
                MessageBox.Show("输入正确,验证通过","提示:");
            else
                MessageBox.Show("格式有误,请细心!","提示:");
        }
        //定义方法
        public bool IsValidate(string str_person) {
            return System.Text.RegularExpressions.
                Regex.IsMatch(str_person,@"(^\d{18}$)|(^\d{15}$)");
        }

 

相关文章:

  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-09-17
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
猜你喜欢
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案