邮箱与手机做账号的验证实例

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body{margin: 0;padding: 0;}
        .label{float: left;width: 120px;}
        .infobox{width: 200px;}
        .error{color: red;padding-left: 10px;}
        .submit{margin-left: 125px;margin-top: 10px;}
    </style>
    <script src="jquery-1.7.1.min.js"></script>
</head>
<body>
<form id="sign_up" method="post" action="" enctype="multipart/form-data">
    <div><span>Enter age</span>
        <input name="age" type="text" maxlength="20"/>
        <span></span>
    </div>
</form>
<script>
    $(".infobox").on("blur",function(event){
        yanzheng(".error",".infobox",event);
    });
    function yanzheng(classNameHide,inputVal,event){
        var data = $(inputVal).val();
        var test_Express = / /;
        (data.indexOf("@")>0)?(function(){
            test_Express = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

//此处可以显示图片验证码 为邮箱注册提供验证
            testFunction(test_Express);
        })():(function(){

            var noNum = /\d/;

            if(noNum.test(data)){

                test_Express = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;//此处 显示发送 手机验证码请求 的按钮 显示倒计时
            testFunction(test_Express);

}else{alert("您的输入不符合规则,请重新输入")}

           
        })();
        function testFunction(test_press){
            (test_press.test(data))?(function(){
                $(classNameHide).text(" ");//错误提示隐藏
            })():(function(){
                $(classNameHide).text("你的输入格式不符合规则");//错误提示显示
                event.preventDefault();
            })()
        }
    }
</script>
</body>
</html>

你可能感兴趣的:(三目运算,邮箱手机验证)