Email Validate expression .

Posted by sarnaiksuraj-12609 under ASP.NET on 3/6/2013 | Points: 10 | Views : 1217 | Status : [Member] | Replies : 4
Hi
currently i am using following expression for email validation:
"^[a-zA-Z0-9][-\._a-zA-Z0-9]*@[a-zA-Z0-9][-\.a-zA-Z0-9]*\.(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|tv|[a-zA-Z]{2})$"

But i enter email Like that it will accept the mail
suraj.....sarnaik@gmail.......com

But it should validate because before the domain name it should accept only one dot as well as between the name it should accept only one dot.

eg Correct Email: suraj.sarnaik.sp@gmail.com




Responses

Posted by: Karthikreddy on: 3/6/2013 [Member] Starter | Points: 25

Up
0
Down
use this regx it will work fine !!
it will not allow more than one dot


\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

k@rth!k
karthikreddy08a50@gmail.com

sarnaiksuraj-12609, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: sarnaiksuraj-12609 on: 3/6/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks for ur reply Karthikreddy!!
but it allow any domain name like
suraj.s@gmail.vbvbv

i want to validate also domain name in above ex vbvbv its not logically correct domain.


sarnaiksuraj-12609, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 3/6/2013 [Member] Starter | Points: 25

Up
0
Down
hi suraj ,

we con't validate all domain name becoz lacks of domain names exist !!

if you want selected domains mean i suggest you regx \w+([-+.']\w+)*@\w+([-.]\w+)*.(com|in|edu|info|gov|int|mil|org|tv|[a-zA-Z]{2})
it will validate selected domain names and all two char domain names.

thanks for replying

k@rth!k
karthikreddy08a50@gmail.com

sarnaiksuraj-12609, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Asavasamuel on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
Suraj

This is an excellent library for verifying email addresses:
http://www.kellermansoftware.com/p-37-net-email-validation.aspx


sarnaiksuraj-12609, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response