/// <summary> /// 验证手机号 /// </summary> /// <param name="telNum"></param> /// <returns></returns> private static dynamic CheckTelNum(string telNum) { Regex mobileRegex = new Regex("^[0-9]{11,11}"); if (mobileRegex.IsMatch(telNum)) { return new {isTrue = true, message = "验证通过"}; } return new {isTrue = false, message = "验证失败"}; } /// <summary> /// 验证邮箱 /// </summary> /// <param name="email"></param> /// <returns></returns> private static dynamic CheckEmail(string email) { bool result = Regex.IsMatch(email, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); if (result) return new { isTrue = true, message = "验证通过" }; return new { isTrue = false, message = "验证失败" }; } /// <summary> /// 验证数字 /// </summary> /// <param name="num"></param> /// <returns></returns> private static dynamic CheckIntNum(string num) { Regex mobileRegex = new Regex("^[0-9]"); if (mobileRegex.IsMatch(num)) { return new { isTrue = true, message = "验证通过" }; } return new { isTrue = false, message = "验证失败" }; }
时间: 2024-10-11 07:51:51