html页面
<input type="text" id="ZhangHao" name="mobile_phone" class="WenBen_Input" placeholder="请输入注册手机号" autofocus="autofocus" maxlength="11" required="required">
js代码
//验证手机号是否可以注册
$(function(){
$("#ZhangHao").blur(function(){
var mobile_phone=$(this).val();
$.ajax({
url:"{:url('index/Creg/checkPhone')}",
data:{"mobile_phone":mobile_phone},
cache:"false",
async:"true",
dataType:"json",
type:"post",
success:function(data){
if(data=='1'){
}else{
alert("手机号已经注册");
}
},
error:function(){
alert("服务器端异常");
}
});
});
})