JS 验证邮箱的问题

<html>
<head>
<script language="javascript" >
function isText(test){
reg = new RegExp('^[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-z][a-z.]{2,8}$');
if(reg.test(test.value)){
//document.getElementById("emli").innerHTML="可以注册";
return true;

}else
{
return false;
}
}
function eMali(test){
if(isText.test(test)){
document.getElementById('emli').innerHTML="可以注册";
}
else
{
document.getElementById('emli').innerHTML="格式不正确";
}
}
</script>
</head>
<body>
<form method="POST">
<input type="text" name="emi" id="e" onblur='eMali(this)'><br>
<div id="emli"></div>
<input type="submit" name="submit" value="确定" >
</form>
</body>
</html>
======================
哪出错了。 还有我感觉写的正则表达式也有问题
谁给我看看

$(function(){
//email检查
$("#txtEmail").blur(function(){
formFlag.email = false;//将email设置成未通过检查
$("#email\\.info").html("");//清空错误提示
var emailTxt = $(this).val();//用户输入email
var pattern=/\b(^['_A-Za-z0-9-]+(\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/;
if(emailTxt == ""){
$("#email\\.info").html("邮箱地址不能为空!");
}else if(!pattern.test(emailTxt)){
$("#email\\.info").html("邮箱地址格式不正确!");
}else{//唯一性检查
$("#email\\.info").html("正在检测...");
$.post(
"/dang/user/checkemail.action",
{"email":emailTxt},
function(data){//data是服务器返回的ok属性值
if(data){
$("#email\\.info").html("该邮箱地址可用!");
formFlag.email = true;
}else{
$("#email\\.info").html("该邮箱地址不可用!");
}
}
);
}
});
});
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-05-21
function checkemail(){
var temp = document.getElementById("tbEmail");
//对电子邮件的验证
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(temp.value!=""){
if(!myreg.test(temp.value)){
alert('提示:请输入有效的E_mail!');
tbEmail.focus();
return false;}}}
</script>
邮箱:<input type="text" runat="server" id="tbEmail" name="tbEmail" onBlur="checkemail();"/>可参考本回答被网友采纳
第2个回答  2014-03-06
用这个正则表达式^[\da-zA-Z]+(_|)[\da-zA-Z]+@[\da-zA-Z]+.[a-z]+$

具体你可以看看这个列子:http://www.itnet.org.cn/news447.html

第3个回答  2012-10-25
相似回答