0
var str=document.validation.emailcheck.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

I have the following script. I need a script that does not allow users to enter their personal email address such as gmail,yahoo,hotmail, etc.

Hardrada
  • 728
  • 8
  • 19
Manoj Chowdary
  • 97
  • 1
  • 3
  • 15
  • 1
    so... what's the problem, exactly? Apart from you wanting someone to do it for you. – sachleen Nov 21 '12 at 06:57
  • 1
    Be careful doing this. Are you sure you never want Yahoo or Google to be one of your clients? I used to think it unlikely until a rep from Google contacted my boss about our product. – slebetman Nov 21 '12 at 06:58
  • 2
    possible duplicate- http://stackoverflow.com/questions/7083937/validate-and-filter-email-address-with-regex – Buzz Nov 21 '12 at 07:04
  • @sachleen I am new to java script I think this has been used bysome one already..Any suggestions to imporve java script – Manoj Chowdary Nov 21 '12 at 07:04
  • 1
    @ManojChowdary - Use a regex to check if any of the `google,yahoo` exist in the domain of the email address. – Derek 朕會功夫 Nov 21 '12 at 07:05
  • @slebetman Yeah I need this functionality to be done – Manoj Chowdary Nov 21 '12 at 07:07
  • 2
    @Manoj Chowdary - how to improve? Sit down, read, read a lot, and then show some efforts. Only after that ask. – Bakudan Nov 21 '12 at 07:17

1 Answers1

3

There is no script that can reliably block every single personal email address out there. The variety of email providers is just too large.

Now, technically, you could build a "blacklist" of disallowed domains in the email, like:

var blocked = ["google", "yahoo", "hotmail", "etc"];

And then check if the email address contains any of those, but that would also block anyone working for those companies.

The real question is why you'd want to do this.

Cerbrus
  • 70,800
  • 18
  • 132
  • 147