<input ....手机号码框>
<input type="button" οnclick="checkPhone()">
function checkPhone(){
var zjsjhm = docunent.get...//获取手机号码
if(searchAreaMobilePhoneFromIndex(zjsjhm)){//验证手机号
searchMobilePhoneGuiSuArea(zjsjhm);//查询手机归属地
};
}
//验证手机号
function searchAreaMobilePhoneFromIndex(mobileNo){
if (mobileNo == "") { alert("手机号不能为空"); return (false); }
if (mobileNo.length != 11) { alert("请输入11位手机号"); return (false); }
if (isNaN(mobileNo)){ alert("请输入11位数字"); return (false); }
return true;
}
//查询手机归属地
function searchMobilePhoneGuiSuArea(mobileNo){
var $searchPhonearea = $("#searchPhoneArea");
$searchPhonearea.html("<div class='loadingdiv' style='width:150px;'><div class='loadingArea'>查询中,请稍候...</div></div>");
$.ajax({
type: "get",
url: 'http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel='+mobileNo,
dataType: "jsonp",
jsonp: "callback",
success: function(data){
alert(data);
var mobilehtml = "";
//$('.error').css('display','none');
var province = data.province,
operators = data.catName,
num = data.telString;
$searchPhonearea.html(num+";"+province+";"+operators);
//$('.province span').html(province);
//$('.operators span').html(operators);
},
error:function (){
//$('li span').html('');
//$('.error').css('display','block');
}
});
}