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

判断手机运营商

时间:2016-01-20 15:44:14      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE>
<html>
 <head>
  <title> New Document </title>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <link rel="stylesheet" type="text/css" href="">
  <script type="text/javascript" src="jquery-1.8.3.min.js">
  </script>
  <style type="text/css">
    div{color:red;height:25px;border:1px solid #000;line-height:25px;}
  </style>
 </head>

 <body>
 <input type="text" class="shuru">
 <div class="hao_div"></div>
 <div class="operator">运营商</div>
 </body>
 <script type="text/javascript">
 <!--
    var $oper_tex=$(".operator");
    $(".shuru").keyup(function(){        
        var $inp_val = $(".shuru").val();
            $(".hao_div").text($inp_val); 
            var $haoduan =  $inp_val.substring(0,3); //获取手机号前三位
            if ($inp_val.length == 11)
            {
                test2($haoduan);
            }
            else if ($inp_val.length > 11)
            {
                $oper_tex.text("请输入正确手机号码")
            }
            else if ($inp_val == "")
            {
                 $oper_tex.text("")
            }
    });
    function test2(zhi){
        var haoduan = {
            "134":"1","135":"1","136":"1","137":"1","138":"1","139":"1","150":"1","151":"1","152":"1","158":"1", "159":"1", "182":"1", 
            "183":"1", "184":"1", "157":"1","187":"1", "188":"1", "147":"1", "178":"1",//中国移动
            "130":"2","131":"2","132":"2","155":"3","156":"2","185":"2","186":"2", //中国联通
            "133":"3","153":"3","189":"3","180":"3","181":"3",  //中国电信
        }
        switch (haoduan[zhi])
        {
         case "1":
         $oper_tex.text("中国移动");
         break;
         case "2":
         $oper_tex.text("中国联通");
         break;
         case "3":
         $oper_tex.text("中国电信");
         break;
        }
    }
 //-->
 </script>
</html>

判断手机运营商

标签:

原文地址:http://www.cnblogs.com/liuna/p/5145375.html

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