标签:result str element 判断 cli bsp click nbsp res
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(‘您输入的邮箱有误‘)
}
}
标签:result str element 判断 cli bsp click nbsp res
原文地址:http://www.cnblogs.com/ninetyfive/p/6027568.html