<!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>
function isyx(yx){
var reyx= /^([a-za-z0-9_-])+@([a-za-z0-9_-])+(.[a-za-z0-9_-])+/;//使用正则
return(reyx.test(yx));
}
function checkemail(){
var email = document.getelementbyid('email').value;
if( isyx(email) )
{
alert('正确邮箱地址');
}
else
{
alert('你输入的不是邮箱地址');
}
}
</script>
</head>
<body>
<form id="myfm" name="myfm" method="post" >
<label for="textfield"></label>
<input type="text" name="email" id="email" />
<input type="button" name="button" id="button" value="验证" onclick="网页特效:checkemail();" />
</form>
</body>
</html>
<!--
测试,
输入 www.111cn.net 提示:你输入的不是邮箱地址
输入 wwww@111cn.net 正确邮箱地址