How to validate an email address using RegexValidator

By Ghanashyam Nayak Nov 16, 2011
Using the RegexValidator, you can check and validate an email address and display a proper message.
See Below Code :


 [RegexValidator
( @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$"
, MessageTemplate="Please Enter Correct Email Id..."
)
]

Ghanashyam Nayak

To know more about me, you can follow me on Facebook :http://www.facebook.com/nayak.ghanashyam

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs