<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>指定邮箱匹配</title>
</head>
<body>
<p>以下为指定邮箱匹配,@后指定字符</p>
<p>163email@intra.com</p>
<p>163email@casetekcorp.com</p>
<p>163email@apple.com</p>
<p>163email@intra.apple.com</p>
<p>163email@intra.casetekcorp.com</p>
<input type="text" name="" id="email" value="163email@qq.com" />
<button type="button" onclick="matching()">确定</button>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function matching(){
var email = $("#email").val();
//163email@intra.com
var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@(intra|casetekcorp|apple)+\.(com)$/;
//163email@intra.apple.com
var reg2 = /^([a-zA-Z]|[0-9])(\w|\-)+@(intra|casetekcorp|apple)+\.(casetekcorp|apple)+\.(com)$/;
console.log(reg.test(email),reg2.test(email))
if(reg.test(email)|| reg2.test(email)){
alert("邮箱格式正确");
}else{
alert("邮箱格式不正确");
}
}
</script>
</html>
以上为自行改造,仅供参考~