[thelist] JS regex help

brian cummiskey brian at hondaswap.com
Thu Oct 7 15:06:24 CDT 2004


Hi all-

I'm "borrowing" [0] a regular expression function to check a valid email 
addreess structure on form submit (local intranet, controled js on 
environment) that looks like:

function validateEmail( strValue) {
var objRegExp  = 
/(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

   return objRegExp.test(strValue);
}


the function works great- but it doesn't check for non-tld domains, such 
as .cc, .info to name a couple.

it seems to only like .com, org, biz, and gov.

How can i extend this to include these other domains--  or even better, 
as long as the last 3 characters are ".XX" as in, ".cc" or anything 
else, i will let it pass.



[0] http://www.rgagnon.com/jsdetails/js-0063.html


More information about the thelist mailing list