//检验电子邮件地址是否合法
function isemail(email) {
var endvalue,allowstrlist;
endvalue=true;
if (email.lastIndexOf("@")==-1 || email.lastIndexOf(".")==-1) {
endvalue=false;
}
if (email.indexOf("@",email.indexOf("@")+1)!=-1 || email.indexOf(".",email.indexOf("@"))==-1) {
endvalue=false;
}
if (email.substr(0,1)=="@" || email.substr(0,1)=="." || email.substr(email.length-1,1)=="@" || email.substr(email.length-1,1)==".") {
endvalue=false;
}
allowstrlist="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@";
for (i=0;i<email.length;i++) {
if (allowstrlist.indexOf(email.substr(i,1))==-1) {
endvalue=false;
break;
}
}
return(endvalue);
}
function isemail(email) {
var endvalue,allowstrlist;
endvalue=true;
if (email.lastIndexOf("@")==-1 || email.lastIndexOf(".")==-1) {
endvalue=false;
}
if (email.indexOf("@",email.indexOf("@")+1)!=-1 || email.indexOf(".",email.indexOf("@"))==-1) {
endvalue=false;
}
if (email.substr(0,1)=="@" || email.substr(0,1)=="." || email.substr(email.length-1,1)=="@" || email.substr(email.length-1,1)==".") {
endvalue=false;
}
allowstrlist="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@";
for (i=0;i<email.length;i++) {
if (allowstrlist.indexOf(email.substr(i,1))==-1) {
endvalue=false;
break;
}
}
return(endvalue);
}
<?php
if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)) {
echo "您的 E-mail 通过初步检查";
}
?>
请高手看一下
if(!(theForm.email.value.search("@")))
{
theForm.email.focus();
theForm.email.select();
alert("email地址不合法,请重新输入!")
return false;
}这个为什么不能检查email???
{
return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
}稍微改一下吧!