<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>onfocus</title>
<script type="text/javascript">
function myfocus(txt){
txt.value="";
}
function myblur(txt){
var txtVal = txt.value;
var regexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
var msg = document.getElementById("Msg");
if(regexp.test(txtVal)){
//alert('成功');
msg.innerHTML="<font color='green'>成功</font>";
}else{
//alert('失败');
msg.innerHTML="<font color='red'>失败</font>";
}
}
</script>
</head>
<body>
<input type="text" name="email" value="请输入您的邮箱号" onfocus="myfocus(this)" onblur="myblur(this)"/>
<!-- 通过样式属性display:inline代表在一行中显示 -->
<div id="Msg" style="display:inline"></div>
</body>
</html>