-5

Need regular expression to validate email address also if user don't have email, user able to type 'No Email'. such that regular expression should validate 'No Email' as a valid string.

Abbas
  • 14,186
  • 6
  • 41
  • 72
  • 6
    First question, zero effort. Classic.. – Soner Gönül Jan 15 '14 at 09:21
  • possible duplicate of [Using a regular expression to validate an email address](http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address) – Kippie Jan 15 '14 at 09:22
  • Please read this stackoverflow.com/questions/how-to-ask as it stands this is a very low quality question – Liath Jan 15 '14 at 09:22
  • 3
    Ignoring the fact that this question has been asked alot already, what kind of user experience forces a user to type an exact string "No Email" just to point out they don't have one? – Kippie Jan 15 '14 at 09:24
  • 1
    @Kippie, indeed. Why not just leave it blank and state the field is optional. :) – Moo-Juice Jan 15 '14 at 09:25

2 Answers2

0

You can combine your regex with an or expression |

var regex = "(.+@.+\..+|No Email)"

The validation part need some improvement (not RFC compliant) but you get the idea.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
0
 @"^(([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)|(No Email))$"
Rayet
  • 298
  • 1
  • 11