用Javascript统计“.”的个数,我怎么统计不出来呀?
DX好!请看代码
function checkstr()
{
smtpstr="smtp.163.com";
p=0;
for (k=0;k<smtpstr.lenght;k++)
{
if (smtpstr.charAt(k)==".")
{
p++;
}
}
if (p==0)
{
alert("Smtp服务器格式不正确!");
document.mailset.smtpserver.focus();
return false;
}
return true;
}
在这段代码中smtpstr.charAt(k)=="."好向永远不成立,不管smtpstr等于什么字符串,p总是等于0,请DX指点!!谢谢