在Visual studio 2005中用C#语言编写验证身份证格式是否正确的代码怎么写?

2024-12-13 00:40:48
推荐回答(1个)
回答1:

导入using System.Text.RegularExpressions;
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
Regex EmailExpression = new Regex(@"[\d]{6}(19|20)*[\d]{2}((0[1-9])|(11|12))([012][\d]|(30|31))[\d]{3}[xX\d]*", RegexOptions.Singleline | RegexOptions.Compiled);
if (EmailExpression.IsMatch(TextBox4.Text))
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "");
return;
}
}