0

I've regular expression to validate the email address as below

var reg = /^([A-Za-z0-9_\-\+\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

please help me to validate the entered email so that the input box should accept all special characters listed below.

 .!#$%^&*-=_+{}|/?`

thanks in advance

Abhineet Verma
  • 1,008
  • 8
  • 18
gowtham kumar
  • 227
  • 5
  • 10

1 Answers1

3

E-mail addresses are barely worth validating as legitimate e-mail addresses can contain almost anything (why would you want to tell someone their e-mail address is not valid?). The only way to be sure anyway will be to send them an e-mail with a confirmation link in it. The fact of the matter is if you don't want to exclude any possibly valid e-mail addresses you'll end up with something really permissive like this: \w+\@\w+.\w+

Vala
  • 5,628
  • 1
  • 29
  • 55
  • +1 the permissive approach really is the most reliable, take pity on people @ .museum http://programmers.stackexchange.com/questions/78353/how-far-should-one-take-e-mail-address-validation – Alex K. Sep 27 '11 at 11:03
  • need to validate for providing email service – gowtham kumar Sep 27 '11 at 11:04
  • But you can't know whether or not the e-mail address is valid even if it passes your (arbitrary) rules. If you add the punctuation you've mentioned to the "valid" characters list, what about the x number of other perfectly valid characters real people have in their real e-mail addresses that still aren't on that list. Anything passing the regex I provided you can try to send an e-mail to. If sending fails, it's invalid. – Vala Sep 27 '11 at 11:36