js验证电子邮箱,js验证email合法性,javascript验证电子信箱

来源:互联网 发布:阿芙精油 知乎 编辑:程序博客网 时间:2024/04/30 23:58
<script>
function Juge(theForm)
{
  if (theForm.txtemail.value == "")
  {
    alert("请输入电子信箱!");
    theForm.txtemail.focus();
    return (false);
  }
  else{
    var temp = document.getElementById("txtemail");
 //对电子邮件的验证
 var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  if(!myreg.test(temp.value)){
   alert('提示:请输入有效的E_mail!');
            return (false);
   txtemail.focus();
  }
 
  }
 if (theForm.txtcontent.value == "")
 {
  alert("请您输入您的留言内容");
  theForm.txtcontent.focus();
  return (false);
 }
 if (theForm.txtcode.value == "")
 {
  alert("请输入验证码");
  theForm.txtcode.focus();
  return (false);
 }
}
</script>