日期:2014-05-16  浏览次数:20348 次

为什么我这个怎错了还能提交的?
<!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>
<script type="text/javascript">
function chkmail(){
var temp = document.getElementById("mail");
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
 if(!myreg.test(temp.value))
{
alert('提示\n\n请输入有效的E_mail!');
  myreg.focus();
  return false;
  }

}
</script>
<body>
<form action="http://www.baidu.com" method="get" onsubmit="return chkmail();">
<table width="100%">
  <tr>
  <td width="6%">邮箱:</td>
  <td width="18%"><input type="text" name="mail" value="" id="mail" class="contact_huibox" style="width:109px;"/></td>
  <td width="30%"><input type="submit" name="contact" class="contact_btn" value="提交"/></td>
  </tr>
</table>
</form>
</body>
</html>


------解决方案--------------------
JScript code
//myreg.focus();
temp.focus();