[thelist] JS regex help

Maximillian Schwanekamp lists at neptunewebworks.com
Thu Oct 7 15:32:49 CDT 2004


brian cummiskey wrote:

> 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.

Try this (untested):
var objRegExp  = 
/(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{2,4})(\.[a-z]{2})*$)/i;
Note the {2,4} is the only change.
-- 
Maximillian Von Schwanekamp
Dynamic Websites and E-Commerce
NeptuneWebworks.com <http://www.neptunewebworks.com/>
voice: 541-302-1438
fax: 208-730-6504



More information about the thelist mailing list