Solved

How to block user registration with free email accounts  (@gmail, @hotmail, @yahoo, etc)

Posted on 2006-10-29
5
1,259 Views
Last Modified: 2012-08-14
I have a Web form that provides basic user registration information

One of the field on the form is EMAIL ADDRESS and i want to ensure that no use can register with free email account like (@gmail, @hotmail, @yahoo, etc)

I am using ASP.net 2.0
0
Comment
Question by:GSK_DEV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17831628
I would make a new table in your db with "not allowed" domains for registering, then use some javascript validation or regex for client side validation and do a server side validation or sproc that checks the other table before registering the user, maybe return an int of specifc code eg -10 then you can check the return value in the data layer and take the neccessary action.
0
 
LVL 1

Author Comment

by:GSK_DEV
ID: 17831636
I was wondering if there is any regex pattern to perform the operation. The solution with the database record compare is known to me.
0
 
LVL 27

Accepted Solution

by:
Sammy earned 250 total points
ID: 17831780
Try something like this
'VB.NET
Dim MatchResults As Match
Try
      Dim RegexObj As New Regex("^[A-Z0-9._%-]+@[A-Z0-9-][gmail|hotmail|yahoo|aol]+\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
      MatchResults = RegexObj.Match(SubjectString)
      If MatchResults.Success Then
            'Found a free email gmail,yahoo,hotmail,aol
      Else
            'Valid Email
      End If
Catch ex As ArgumentException
      'oops we have a problem in the pattern
End Try

//C#
Match MatchResults = null;
try {
      Regex RegexObj = new Regex("^[A-Z0-9._%-]+@[A-Z0-9-][gmail|hotmail|yahoo|aol]+\\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$",
            RegexOptions.IgnoreCase | RegexOptions.Multiline);
      MatchResults = RegexObj.Match(SubjectString);
      if (MatchResults.Success) {
            //Found a free email gmail,yahoo,hotmail,aol
      } else {
            //Valid Email
      }
} catch (ArgumentException ex) {
      // oops we have a problem in the pattern
}


HTH
0
 
LVL 1

Author Comment

by:GSK_DEV
ID: 17832046
What is the "SubjectString" ??
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17838194
Substring should hold the value from the Textbox where users type in their email address
or if you want, you can use the textbox directly as mytextbox.Text

0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question