/// <summary> /// 通用验证类 /// </summary> class DataValidate { /// <summary> /// 验证正整数 /// </summary> /// <param name="txt"></param> /// <returns></returns> public static bool IsInteger(string txt) { Regex objReg = new Regex(@"^[1-9]d*$"); return objReg.IsMatch(txt); } /// <summary> /// 验证是否是Email /// </summary> /// <param name="txt"></param> /// <returns></returns> public static bool IsEmail(string txt) { Regex objReg = new Regex(@"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*"); return objReg.IsMatch(txt); } /// <summary> /// 验证身份证 /// </summary> /// <param name="txt"></param> /// <returns></returns> public static bool IsIdentityCard(string txt) { Regex objReg = new Regex(@"^(d{15}$|^d{18}$|^d{17}(d|X|x))$"); return objReg.IsMatch(txt); }