改进的email检查js脚本

1 function isEmail(str)
2 {
3 // are regular expressions supported?
4 var supported = 0 ;
5 if (window.RegExp) {
6 var tempStr = " a " ;
7 var tempReg = new RegExp(tempStr);
8 if (tempReg.test(tempStr)) supported = 1 ;
9 }
10 if ( ! supported)
11 return (str.indexOf( " . " ) > 2 ) && (str.indexOf( " @ " ) > 0 );
12 var r1 = new RegExp( " (@.*@)|(\\.\\.)|(@\\.)|(^\\.) " );
13 var r2 = new RegExp( " ^.+\\@(\\[?)][a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$ " );
14 return ( ! r1.test(str) && r2.test(str));
15 }

你可能感兴趣的:(改进的email检查js脚本)