JS e-mail Validator  

NOTE: I have avoided character classes to aid understanding for newbies. Wizards, bear with the verbosity!

Came up with this nice little email validator JS regexp. Someone got something shorter?

function validateEmail( email ){
var emailRe = new RegExp("^[a-zA-Z]+([a-zA-Z0-9_]*.[a-zA-Z0-9_]+)*@([a-zA-Z0-9_]+.[a-zA-Z0-9_]+)*$",'i');
return( emailRe.test( email ) );

Does this miss any cases? Try it out here:

Update: This script allowed ‘*’ in the email ID. The correct re would be:

var emailRe = new RegExp("^[a-zA-Z]+([a-zA-Z0-9_].[a-zA-Z0-9_]+)+@([a-zA-Z0-9_]+.[a-zA-Z0-9_]+)+$",‘i’);

Bug again! The ‘.’ character outside the character class [] matches ANY single character. This, however, definitely works!

var emailRe = new RegExp("^[a-zA-Z]+([a-zA-Z0-9_.][a-zA-Z0-9_]+)+@([a-zA-Z0-9]+([.a-zA-Z0-9_])+)$".‘i’);
The test code now does not permit ‘*’ in the email ID.