写的一个判断注册Email是否是个人邮件,而不是公司邮件的方法
以下这个方法其实也不是很全面,它只判断了hotmail, gmail和yahoo
如果你还需要加上其他认为是私人Email的Email, 只要按照同样的方法自己加上就可以了
Public void CheckPersonalEmail(ByVal sender As Object, ByVal email As ServerValidateEventArgs) { string strEmail = email.Value.ToLower; var r = New Regex("([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$", RegexOptions.IgnoreCase); if((strEmail <> "") And (strEmail.IndexOf("hotmail") = -1) And (strEmail.IndexOf("gmail") = -1) And (strEmail.IndexOf("yahoo") = -1) And (r.Match(strEmail).Success)) email.IsValid = true if (!email.IsValid) { If (strEmail = "") CustomValidator1.ErrorMessage = "<br />Please enter an email address" If ((strEmail.IndexOf("hotmail") > -1) Or (strEmail.IndexOf("yahoo") > -1) Or (strEmail.IndexOf("gmail") > -1)) CustomValidator1.ErrorMessage = "<br />You cannot use a personal email address" If (!r.Match(strEmail).Success) CustomValidator1.ErrorMessage = "<br />You must enter a valid email address" } }
基于vb.net我自己改写的,可能有的地方语法不正确,自己在Visual Studio中更改就好