<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证邮箱格式</title>
</head>
<body>
<span style="background:#09F; color:#FFF;">以下代码由百度Javascript吧提供,欢迎前来交流学习!</span><br />
<input type="text" onblur ="checkMail(this)" /><span id="error" style="color:#F00; font-size:12px;"></span><br />
<input type="text" />
</body>
</html>
<script>
function isEmail(strEmail)
{
if (strEmail.search(/^\w+((-\w+)丨(\.\w+))*\@[A-Za-z0-9]+((\.丨-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1)
return true;
else
return false;
}
var errorMsg = document.getElementById("error");
function checkMail(node){
var mail = node.value;
errorMsg.innerHTML = isEmail(mail)?"格式正确":"格式错误!";
errorMsg.style.color = isEmail(mail)?"green":"red";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证邮箱格式</title>
</head>
<body>
<span style="background:#09F; color:#FFF;">以下代码由百度Javascript吧提供,欢迎前来交流学习!</span><br />
<input type="text" onblur ="checkMail(this)" /><span id="error" style="color:#F00; font-size:12px;"></span><br />
<input type="text" />
</body>
</html>
<script>
function isEmail(strEmail)
{
if (strEmail.search(/^\w+((-\w+)丨(\.\w+))*\@[A-Za-z0-9]+((\.丨-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1)
return true;
else
return false;
}
var errorMsg = document.getElementById("error");
function checkMail(node){
var mail = node.value;
errorMsg.innerHTML = isEmail(mail)?"格式正确":"格式错误!";
errorMsg.style.color = isEmail(mail)?"green":"red";
}
</script>