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;
}
*******************************************
* or *
*******************************************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 ifend function
{
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;
}
*******************************************
* or *
*******************************************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 ifend function
// function CheckEmail(value)
// --------------
// 功能:检查Email是否合法
// 传入参数:
// value: 要进行检查的Email地址
// 传出结果: 返回是否合法 false: 错误 true:合法
// *********************************************************************************** //
function CheckEmail(value)
{
value = Trim(value);
var emailexp = /^$|^[a-z][a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]+$/i;
return emailexp.test(value);
}
// **************************************************************** //
// function Trim(value)
// --------------
// 功能:删除两端空格(= trim)
// 参数: value 要格式化的字符串
// 返回: 格式化后的字符串
// **************************************************************** //
function Trim(value){
var res = String(value).replace(/^[\s]+|[\s]+$/g,'');
return res;
}