Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1350
  • Last Modified:

textbox validation exclude gmail and hotmail emails

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
clearchannel
Asked:
clearchannel
  • 3
  • 3
1 Solution
 
Michel PlungjanIT ExpertCommented:
<script>
var reg = /@hotmail|@gmail|@live\.|@googlemail/
var email = 'asdsa@gmail.com'
alert(reg.test(email.toLowerCase()))
</script>
0
 
clearchannelAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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
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!

 
clearchannelAuthor Commented:
Maybe someone with .net skills can answer for me as I do tno think your regexp will will in .net validation control.
 
0
 
clearchannelAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now