Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

15 Experts available now in Live!

Get 1:1 Help Now