jquery.validate.js remote 返回不同结果的错误提示的代码

//保单号的校验
jQuery.validator.addMethod("policyNoCheck", function (value, element, param) {
    var flag = true ;
    var result = '' ;
    $.ajax({
        url : ctx + "/sys/vehicle/authc_json/checkPolicyNo.shtml",// 请求的URL
        data : {
            policyNo : value
        },
        async : false, // 改异步为同步
        dataType : 'json',
        success : function(data) {
            if(data.resultCode == 0) {
                var userInsurencePoint = data.data;
                if (userInsurencePoint.handle ) {
                    flag = false;
                    result = "您录入的保单号已经分配积分了,积分有" + userInsurencePoint.point;
                } else {
                    $("#givePointForm input[name='phone']").val(userInsurencePoint.insuredPhone);
                    flag = true ;
                }
            }else{
                flag = false ;
                result = "您录入的保单号不存在" ;
            }
        }
    });
    $.validator.messages.policyNoCheck = result;
    return flag;
}) ;                               
function checkFormPoint() {
    validatorPoint = $("#givePointForm").validate({
        //    onfocusout: false,  //失去焦点
        onkeyup: false, // 键盘是否按下
        //onclick: false,  //是否单击
        rules: {
            licenseNo: {
                required: true,
                policyNoCheck: true
            },
            phone: {
                required: true
            },
            code: {
                required: true,
                isSixNum: true
            },
            showPoint: {
                required: true
            }
        },
        messages: {
            licenseNo: {
                required: "请录入车牌号"
            },
            phone: {
                required: "填写没有赠送金币的保单号会自动显示出来"
            },
            code: {
                required: "点击发送获取手机验证码",
                isSixNum: "手机验证码位为6位数字"
            },
            showPoint: {
                required: "请填写您需要赠送给用户的金币"
            }
        }
    });

}

你可能感兴趣的:(java,代码)