<script type="text/javascript"> //验证邮箱格式 function isEmail() { var email = document.getElementById("zh_e").value; if(email == "") { alert("请输入邮箱!"); document.getElementById("zh_e").focus(); return false; } var pattern = /^([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/; strEmail = pattern.test(email); if(strEmail) { return true; } else { alert("邮箱格式不正确!"); } } </script> 实现功能:当鼠标焦点离开文本框时触发该事件。onblur=“isEmail” [ onblur()失去焦点时触发事件 ] <body> <input type="text" maxlength="32" style="220px;" onblur="isEmail()" id="zh_e" /> </body>