Solved

textbox validation exclude gmail and hotmail emails

Posted on 2009-04-07
6
1,313 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
  • 3
  • 3
6 Comments
 
LVL 75

Accepted Solution

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

Author Comment

by:clearchannel
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

743 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

18 Experts available now in Live!

Get 1:1 Help Now