码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2015-02-09 20:23:44      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://my.oschina.net/530520/blog/376836

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!