1.
if (!TelphoneHelper2.IsTelphone(mobile)
{
MessageBox.Show("请录入正确的手机号!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
2.TelphoneHelper2.cs
1 2 3 4 5 6 7 8 9 10 | public class TelphoneHelper2 { public static bool IsTelphone(string tel) { String strExp = @"[0-9][0-9][0-9]{9}"; Regex r = new Regex(strExp); Match m = r.Match(tel); return m.Success; } } |
原文:https://www.cnblogs.com/lonelyxmas/p/12655030.html