邮箱验证js

HTML代码:

<div class="reg_con" style="position:relative;">

    <label>公司邮箱</label>

    <input type="text" name="email" value="输入邮箱如:[email protected]" class="inp"         id="email"/>

    <div id="email_text" style="position:absolute; right:-80px;top:20px; color:#c00;             font-weight:bold;">

    </div>

</div>

Js代码:

$("#email").blur("blur",function(){

    var email = $("#email").val();

    var Regex = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 

    if($("#email").val()==""){

        $("#email_text").html("邮箱信息不能为空");

    }

    else

    {

        if(Regex.test(email)){

            $("#email_text").html("");

        }else{

            $("#email_text").html("邮箱格式验证错误");

        };

    };

});


你可能感兴趣的:(js,验证,邮箱)