var btn = document.getElementById('btn');
var txt = document.getElementById('txt');
btn.onclick = function(){
var str = txt.value;
var reg = /^[a-zA-Z0-9]+@[a-z0-9]{2,5}\.[a-z]{2,3}(\.[a-z]{2,3})?$/;
var result = reg.test(str);
if(result){
alert('是正确的邮箱');
}else{
alert('您输入的邮箱有误')
}
}