Chinaunix首页 | 论坛 | 博客
  • 博客访问: 793974
  • 博文数量: 247
  • 博客积分: 166
  • 博客等级: 入伍新兵
  • 技术积分: 2199
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-15 16:10
文章分类

全部博文(247)

文章存档

2017年(1)

2015年(63)

2014年(80)

2013年(94)

2012年(9)

分类: JavaScript

2013-08-09 14:19:27

方式一:
 function isEmail(strEmail) {//邮箱验证
             if (strEmail.search(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/) == -1) {
                  document.getElementById ("emailInf").innerHTML="格式不对!";
                  document.getElementById ("emailInf").style.color="red";
              } else {
                  document.getElementById ("emailInf").innerHTML="通过!";
                  document.getElementById ("emailInf").style.color="green";
                  document.getElementById ("emailCheck").innerHTML="";
              }
//               alert("Email格式不正确!");
               
               
//               document.formSignUp.email.value="";
//               document.formSignUp.email.focus();
}

方式二:
function chkemail(form){
        if (form.email.value==""){
                email1.innerHTML="请输入E-mail地址!"; 
                return;
        }
       var MyEmail = document.getElementById("txtEmail").value;
       var IfExistAt = MyEmail.indexOf("@");//判断是否存在"@",不存在返回为负数。
       var IfExistDot = MyEmail.indexOf(".");//判断是否存在"."。
       if (IfExistAt>=0&&IfExistDot>=0) //"@"和"."都存在
       {
              if(IfExistAt==0||IfExistDot==0)
              {
                alert("格式不正确,@或.不能出现在第一位");
              }
              else if (IfExistDot-IfExistAt>1) //判断@与.之间可有字符
              {
                 alert("输入正确");
              }
              else
              {
                alert("输入错误,@与.之间必须有字符");
              }
              }
               else
              {
                     alert("格式不正确,缺少@或.字符");
               } 
      }
}
阅读(961) | 评论(0) | 转发(0) |
0

上一篇:简单登陆界面

下一篇:java引入jar包

给主人留下些什么吧!~~