if (theForm.mail.value == "")
{
alert("留个邮箱吧,以后忘记密码有用哦!");
theForm.mail.focus();
return (false);
}
if (theForm.mail.value.length > 100)
{
window.alert("哇~~这信箱也太长了吧?有30个字都很夸张啦!^_^");
return false;
}
var regu = "^(([0-9a-zA-Z]+) ¦([0-9a-zA-Z]+[.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2} ¦net ¦NET ¦com ¦COM ¦gov ¦GOV ¦mil ¦MIL ¦org ¦ORG ¦edu ¦EDU ¦int ¦INT)$"
var re = new RegExp(regu);
if (theForm.mail.value.search(re) != -1) {
return true;
} else {
window.alert ("嗯,这信箱怎么有点怪怪的呢?^^")
return false;
}
---------------------------------------------------------------
判断输入的email地址是否合法:
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function