var temp = "1234567890-_abcdefghijklmnopqrstuvwxyz";
function IsMail(strMail)
{
if(strMail.length > 100 ) return false;
var preIsSpecial = false;
var isHasAt = false;
var countAfterAtDot = 0;
for(var i = 0;i < strMail.length;i++)
{
char = strMail[i];
if(IsCharactor(char))
{
preIsSpecial = false;
continue;
}
if(char == '@')
{
if(isHasAt) return false;
isHasAt = true;
preIsSpecial = true;
}
if(char == '.')
{
if(preIsSpecial) return false;
if(i == 0 && i == strMail.length-1) return false;
if(isHasAt) countAfterAtDot++;
preIsSpecial = true;
}
}
if(preIsSpecial == true || isHasAt == false || countAfterAtDot == 0) return false;
return true;
}
function IsCharactor(char)
{
if(char.length > 1) return false;
if(temp.indexOf(char.toLowerCase()) != -1) return true;
else return false;
}
var temp = "1234567890-_abcdefghijklmnopqrstuvwxyz";
function IsMail(strMail)
{
if(strMail.length > 100 ) return false;
var preIsSpecial = false;
var isHasAt = false;
var countAfterAtDot = 0;
for(var i = 0;i < strMail.length;i++)
{
char = strMail[i];
if(IsCharactor(char))
{
preIsSpecial = false;
continue;
}
if(char == '@')
{
if(isHasAt) return false;
isHasAt = true;
preIsSpecial = true;
}
if(char == '.')
{
if(preIsSpecial) return false;
if(i == 0 && i == strMail.length-1) return false;
if(isHasAt) countAfterAtDot++;
preIsSpecial = true;
}
}
if(preIsSpecial == true || isHasAt == false || countAfterAtDot == 0) return false;
return true;
}
function IsCharactor(char)
{
if(char.length > 1) return false;
if(temp.indexOf(char.toLowerCase()) != -1) return true;
else return false;
}
js检测邮箱地址合法性最快方法(非正则)
最新推荐文章于 2022-09-13 16:30:23 发布
