<!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">
<button id="but1"></button>
<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)
{
$("#but1").click(function(){
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>