Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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