您的位置:首页 > Web前端 > JavaScript

js实现邮箱格式校验

2014-02-28 14:23 232 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/lxwr2010/article/details/20134469

<div style="float:left; width: 20%; height: 40px; margin-top: 12px">
   <strong style="float: right; margin-right: 20px">邮箱:</strong>
  </div>
  <div style="float:left;width: 50%; height: 40px;margin-top: 12px">
   <div>
          <input id="eMail" type="text" value="" placeholder="邮箱格式" class="form-control" οnblur="eMailCheck()"/>
         </div>
  </div>
  <div style="float:left; width: 15%; height: 40px; margin-top: 15px;">
   <label id="eMailMsg" style="float:left; color: red; font-size: 12px; margin-left:10px "></label>
  </div>

 

var RegEmail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

function eMailCheck(){
 var account = $("#eMail").val();
 if( account != "" && !RegEmail.test(account)) {
   $("#eMailMsg").html("邮箱格式不正确");
  }else {
   $("#eMailMsg").html("");
   }
 }

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: