Solved

textbox validation exclude gmail and hotmail emails

Posted on 2009-04-07
6
1,331 Views
Last Modified: 2012-06-22
I have been looking for a regular expression for an asp.net textbox ('tbEmail') so that NO Hotmail or GMail addresses are allowed but have been unsuccessful. Please could an expert point me to something that will get the job done or supply some code to do the above?
0
Comment
Question by:clearchannel
[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
  • 3
  • 3
6 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
ID: 24085388
<script>
var reg = /@hotmail|@gmail|@live\.|@googlemail/
var email = 'asdsa@gmail.com'
alert(reg.test(email.toLowerCase()))
</script>
0
 

Author Comment

by:clearchannel
ID: 24085567
Ok, does the syntax "/@hotmail|@gmail|@live\.|@googlemail/" work in an asp.net validation control?
 
I should have made the question clearer I want to check for valid email address but exclude gmale, hotmail etc.
 
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24086542
Perhaps not with the / /

Remember to ask if it does NOT match then it is ok

http://msdn.microsoft.com/en-us/library/ms998267.aspx



0
Independent Software Vendors: 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!

 

Author Comment

by:clearchannel
ID: 24095390
Maybe someone with .net skills can answer for me as I do tno think your regexp will will in .net validation control.
 
0
 

Author Comment

by:clearchannel
ID: 24095601
Here is the vb.net code:
If (System.Text.RegularExpressions.Regex.IsMatch(sEmail, "@hotmail|@gmail|@live|@googlemail")) Then
                errorMessage.Text = "The following emails are not valid; Hotmail, GMail, Googlemail and MSN Live"
End If

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24095878
you may want to add a dot to the @live

since it is only @live.com or @live.co.xx which is a new hotmail address
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

738 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