现在的位置: 首页 > 综合 > 正文

javascript-利用正则表达式检查电子邮件格式

2012年09月03日 ⁄ 综合 ⁄ 共 334字 ⁄ 字号 评论关闭

//Check Email Format
function CheckEmail(theform)
{
email=theform.rs_email.value;
if(email=="")
{
alert("邮箱地址不能为空!");
theform.rs_email.focus();
return false;
}
else
{
   var re = /^[\w.-]+@([0-9a-z][\w-]+\.)+[a-z]{2,3}$/i;  

    if(re.test(email))
    {
        return true;
    }
    else
    {
  alert("邮箱地址格式不正确!");
  theform.rs_email.focus();
        return false;
    }
}
}

【上篇】
【下篇】

抱歉!评论已关闭.