textbox中输入email做格式控制

txtEmail.ImeMode = System.Windows.Forms.ImeMode.Disable;


string email = txtEmail.Text.ToString().Trim();

if (email != "")
                {
                    Match m = Regex.Match(email, @"^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$");
                    if (!m.Success)
                    {
                        MessageBox.Show(Client.Properties.Resources.Str_EmailTip);
                        return;
                    }
                }

 

posted @ 2013-06-20 17:11  nygfcn  阅读(256)  评论(0编辑  收藏  举报