input 改变响应

发布于:2015年12月21日 已被阅读

$(function(){
    // var str = $('.no_last').html();
    $('#phone').bind('input propertychange',function(){
        var phone = $(this).val();
        var lphone = phone.length;
        if(lphone == 11){
        // $('.no_last').html("<img src='__RES__/html/images/loading2.gif'>");
            $.ajax({
                url: "{:U('Index/getGoodsByAjax')}",
                data:{'phone':phone},
                type: 'post',
                dataType: 'json',
                async: true, 
                success: function(result) {
                    if (result.status) {
                //         $('#msgtel').text(result.msg);
                //         $('.no_last').html(result.str);
                //         return;
                //         // alert(result.msg);
                //         // location.reload();
                    }else{
                //         $('#telmsg').text(result.msg);
                //         $('.no_last').html(str);
                //         // $('.no_last').html("<li>请输入正确的手机号码</li>");
                //         // alert(result.msg);
                //         return false;
                    }
                }
            });
        }else{
        // $('#telmsg').text('手机号码不正确');
        // $('.no_last').html(str);
        }
    });
  });