Solved

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

Posted on 2006-10-29
5
1,226 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
What is the "SubjectString" ??
0
 
LVL 27

Expert Comment

by:Sammy
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now