HTML+JS

HTML

<input name="mobile" id="mobi" class="number" placeholder="请输入手机号码" type="tel" value="{$user_info.father_phone}" maxlength ="11" autocomplete="off" onKeyUp="mobilecheck()">
<div><span id="city_name"></span></div>
JS

function mobilecheck(){
     var mobile = document.getElementById("mobi").value;
     if(mobile.length==11){
         $.ajax({ 
             url:"http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel="+mobile, 
             type:'GET', 
             dataType:'JSONP',  
             success: function(data){    
                document.getElementById('city_name').innerHTML = data.carrier;
                if(!data.carrier){
                    document.getElementById('city_name').innerHTML = "手机号码错误";
                }
             }
    }); 
}
else if(mobile.length !=11){
    document.getElementById('city_name').innerHTML = "";
}
}