验证邮箱
<script type="text/javascript">
function check_email(){
var str = document.myform.email.value;
var reg = /^[0-9a-zA-Z_]{5,12}@(163|126|qq|yahoo|gmail|sina)\.(com|com\.cn|cn|la)$/;
if(str.search(reg) < 0){
document.getElementById('emailmsg').innerHTML = '邮箱错误!';
}else{
document.getElementById('emailmsg').innerHTML = '邮箱正确!';
}
}
function check_email(){
var str = document.myform.email.value;
var reg = /^[0-9a-zA-Z_]{5,12}@(163|126|qq|yahoo|gmail|sina)\.(com|com\.cn|cn|la)$/;
if(str.search(reg) < 0){
document.getElementById('emailmsg').innerHTML = '邮箱错误!';
}else{
document.getElementById('emailmsg').innerHTML = '邮箱正确!';
}
}
</script>
<form name="myform">
<p>
邮箱:<input type="text" name="email" onblur="check_email()" />
<font color="red">*</font>
<span id="emailmsg">请输入正确的邮箱</span>
</p>
</form>
<p>
邮箱:<input type="text" name="email" onblur="check_email()" />
<font color="red">*</font>
<span id="emailmsg">请输入正确的邮箱</span>
</p>
</form>