textbox validation exclude gmail and hotmail emails

Posted on 2009-04-07
Last Modified: 2012-06-22
I have been looking for a regular expression for an 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?
Question by:clearchannel
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
LVL 75

Accepted Solution

Michel Plungjan earned 300 total points
ID: 24085388
var reg = /@hotmail|@gmail|@live\.|@googlemail/
var email = ''

Author Comment

ID: 24085567
Ok, does the syntax "/@hotmail|@gmail|@live\.|@googlemail/" work in an validation control?
I should have made the question clearer I want to check for valid email address but exclude gmale, hotmail etc.
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

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

Author Comment

ID: 24095601
Here is the 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

LVL 75

Expert Comment

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

since it is only or which is a new hotmail address

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)

687 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