用Javascript验证email填写是否正确

发表于:2007-06-21来源:作者:点击数: 标签:

   

<html>
<head>
<title>test</title>
<script language="javascript">
function emailCheck () {
var emailStr=document.all.form1.tel.value;
alert(emailStr);
var emailPat=/^(.+)@(.+)$/;

var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
 alert("电子邮件地址必须包括 ( @ 和 . )")
 return false;
}
return true;
}
</script>
</head>


<body>
<form name="form1">
<input type="text" name="tel"/>
<input type="button" value="press" onclick="emailCheck()"/>
</form>



</span>
</body>
</html>

原文转自:http://www.ltesting.net