<!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=gb2312" />
<title>js 验证邮箱正则表达式</title>
<script>
var tempv = document.all(ctrl).value;
var ctrlid = document.all(ctrl).id;
var emailpat=/^(.+)@(.+)$/;
var matcharray=tempv.match(emailpat);
//alert("matcharray="+matcharray);
if(matcharray == null)
{
alert("e-mail地址错误!");
document.all(ctrl).focus();
return false;
}
else
{
return true;
}</script>
</head><body>
</body>
</html>
时间: 2024-09-20 22:46:00