写的一个判断注册Email是否是个人邮件,而不是公司邮件的方法
2016-09-23 14:54
483 查看
以下这个方法其实也不是很全面,它只判断了hotmail, gmail和yahoo
如果你还需要加上其他认为是私人Email的Email, 只要按照同样的方法自己加上就可以了
基于vb.net我自己改写的,可能有的地方语法不正确,自己在Visual Studio中更改就好
如果你还需要加上其他认为是私人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中更改就好
相关文章推荐
- nc6报错 Failed to load ESAPI.properties as a classloader resource.
- ping不通 www.baidu.com 163.com
- Openfire更服务器名称后报Found RSA certificate that is not valid for the server domain的解决方法
- OpenCV Error: Assertion failed (s >= 0)
- 登录ssh时Host key verification failed错误
- 登录ssh时Host key verification failed错误
- 【行业特稿】人工智能/虚拟现实/大数据/其他科技创业者
- 为什么人工智能现在这么火?
- 解决 ORA-21561: OID generation failed
- Contains Duplicate
- NSBundle 的理解和 mainBundle
- 安装apk时出现错误Failure [INSTALL_FAILED_DEXOPT]问题解决的方法
- AI实验之数据集处理
- 浅析pthread_cond_wait
- wait() 和 waitpid()
- LeetCode笔记:70. Climbing Stairs
- mysql新建root用户报错ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'
- [Angular 2] Generate Angular 2 Components Programmatically with entryComponents & ViewContainerRef
- UNIX Domain Socket使用
- reference other engineer's code to explain wheather linux terminal can display matplotlib' figure