Solved

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

Posted on 2006-10-29
5
1,232 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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