<!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>
<script type="text/JavaScript">
function ck_email()
{
var reg= /^\w+@\w+\.(com|cn|gov)$/;
var str=document.getElementById("email").value;
if (reg.test(str)==true){
document.getElementById("p1").innerHTML="<font color='green' size='2'>符合规则</font>"
return true;
}else {
document.getElementById("p1").innerHTML="<font color='red' size='2'>不符合规则</font>";
return false;
}
}
</script>
</head>
<body>
<form action="01.php" onsubmit = "return ck_email()">
邮箱:<input id="email" οnblur="ck_email()"/><span id="p1"></span><br />
<input type="submit" />
</form>
</body>
</html>