function validateEmail(email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(email) == false) {
return false;
}
return true;
}
Random Posts
About Alpesh Mansata
I am a 25-year-old guy living at a beautiful green city Pune . I have a post graduate degree in Information Technology from K.S.School of Business Management and Research. A Zend certified PHP5 Engineer with over 4 years of experience working with PHP, AJAX, MySql and the Mambo/Joomla CMS.
In my full-time job, I am a Senior Software Engineer working at Xoriant. Most recently, I have been working on SchoolFinder module on www.education.com
In my spare time (if there is such a thing), I volunteer with the Rotaract club of Ahmedabad Airport.
Very cool!

I think there is one bug in the code.. The regex considers “_” in the URL portion as valid email address, though as per URL RFC1738 (http://www.faqs.org/rfcs/rfc1738.html – pls see Section 2.1) valid characters for a URL does not include “_” (underscore).. And I think, I have never seen any URL with underscore in it.. so, email id with an underscore in domain part will always be invalid.
This occured to me just because I’d reported this in one of my products
Thanks Jigar, fixed it.