手机号验证js

html代码:

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

    <label>联系电话</label>

    <input id="telphone" type="text" name="userExt.telphone" value="13800000000"         class="inp" maxlength="11" />

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

    </div>

</div>

JS代码:

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

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

    var myreg = /^1[34578]\d{9}$/;

    if(telphone == ""){

     $("#telphone_tip").html("联系电话不能为空");

    }

    else

    {

     if(myreg.test(telphone)){

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

        }

        else

        {

            $("#telphone_tip").html("联系电话格式不正确");

        };

    };

});



你可能感兴趣的:(js,验证,手机号)