| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Muchinfo.MTPClient.Infrastructure.Helpers
- {
- /// <summary>
- /// 字符串验证公共类 Add By DK 2016-11-22
- /// </summary>
- public static class ValidationHelper
- {
- /// <summary>
- /// 验证手机号码
- /// </summary>
- /// <param name="str_handset"></param>
- /// <returns></returns>
- public static bool IsMobile(string str_handset)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^[1]+[3-9]+\d{9}$");
- }
- /// <summary>
- /// 验证输入为数字
- /// </summary>
- /// <param name="str_number"></param>
- /// <returns></returns>
- public static bool IsNumber(string str_number)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_number, @"^[0-9]*$");
- }
- /// <summary>
- /// 验证电话号码
- /// </summary>
- /// <param name="str_telephone"></param>
- /// <returns></returns>
- public static bool IsTelephone(string str_telephone)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_telephone, @"^(\d{3,4}-)?\d{6,8}$");
- }
- /// <summary>
- /// 验证身份证号
- /// </summary>
- /// <param name="str_idcard"></param>
- /// <returns></returns>
- public static bool IsIDcard(string str_idcard)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_idcard, @"(^(\d{18}$|\d{17}(\d|X|x))$)|(^(\d{15}$|\d{14}(\d|X|x))$)");
-
- }
-
- /// <summary>
- /// 验证邮编
- /// </summary>
- /// <param name="str_postalcode"></param>
- /// <returns></returns>
- public static bool IsPostalcode(string str_postalcode)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_postalcode, @"^\d{6}$");
- }
- /// <summary>
- /// 验证邮箱
- /// </summary>
- /// <param name="str_Email"></param>
- /// <returns></returns>
- public static bool IsEmail(string str_Email)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(str_Email, @"\\w{1,}@\\w{1,}\\.\\w{1,}");
- }
- }
- }
|