<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function verifyAddress(obj)
{
var email = document.haha.address.value;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;
{
var email = document.haha.address.value;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;
flag = pattern.test(email);
if(flag)
{
alert("通过验证");
return true;
}
else
{
if(email=='')
{
alert("邮件地址不能为空");
return false;
}else
{
alert("邮件格式不对");
return false;
}
{
alert("通过验证");
return true;
}
else
{
if(email=='')
{
alert("邮件地址不能为空");
return false;
}else
{
alert("邮件格式不对");
return false;
}
}
}
</script>
</head>
}
</script>
</head>
<body>
<form action="" name="haha">
<input type="text" name="youjian" id="address">
<input type="submit" value="验证" οnclick="verifyAddress(this);">
<input type="text" name="youjian" id="address">
<input type="submit" value="验证" οnclick="verifyAddress(this);">
</form>
</body>
</html>
</body>
</html>