如何像普通的 jquery ajax 一样自定义远程验证?

how to customize remote validation like a normal jquery ajax?

有没有办法像正常的那样自定义远程验证 jquery ajax?

$('#banner').bootstrapValidator({
        framework: 'bootstrap',


        fields: {
            bannerType: {
                icon: false,
                validators: {
                    notEmpty: {
                        message: 'Banner type is required'
                    }
                }
            },
            bannerTitle: {
                icon: false,
                validators: {
                    notEmpty: {
                        message: 'Banner title is required'
                    }
                }
            },

            bfromDate: {
                verbose: true,
                validators: {
                     notEmpty: {
                        message: 'From date is required'
                    },
                    date: {
                        format: 'MM/DD/YYYY',
                        message: 'The value is not a valid date'
                    },
                    remote: {
                    url: '/assets/cfc/exchange/exchangeintra.cfc?method=checkAvailabilityofDates',
                    type: 'POST',
                    dataType:'json',
                     data: function(validator, $field, value) {
                            return {

                                selectedDate: validator.getFieldElements('bfromDate').val(),
                                bannerId: validator.getFieldElements('bannerId').val(),



                            };
                        },

                  }
                }
            },
            btoDate: {
                verbose: true,
                validators: {
                     notEmpty: {
                        message: 'To date is required'
                    },
                    date: {
                        format: 'MM/DD/YYYY',
                        message: 'The value is not a valid date'
                    },
                    remote: {
                    url: '/assets/cfc/exchange/exchangeintra.cfc?method=checkAvailabilityofDates',
                    type: 'POST',
                    dataType:'json',
                    data: function(validator, $field, value) {
                            return {

                                selectedDate: validator.getFieldElements('btoDate').val(),
                                bannerId: validator.getFieldElements('bannerId').val(),


                            };
                        },

                  }
                }
            },
             authorImage: {
                validators: {
                     notEmpty: {
                        message: 'Banner image is required'
                    },
                    file: {
                        extension: 'jpeg,jpg,png',
                        type: 'image/jpeg,image/png',
                        message: 'The selected file is not valid'
                        }
                }
            },
            bannerLink: {
                icon: false,
                validators: {
                    notEmpty: {
                        message: 'Banner link is required'
                    }

                }
            }


        }


    });

当远程验证成功时再做其他事情,如果失败再做其他事情。

我得到了以下 link:http://formvalidation.io/examples/using-data-returned-validator/

但它是有效的,只有当我使用 formvalidation 但我在这里使用 bootstrapValidator.so 有没有办法像 formvalidation 一样做同样的事情。

字段校验完成后,调用onSuccess或onError回调。 以下是解决我的问题的示例代码:

 bfromDate: {
                verbose: true,
                validators: {
                     notEmpty: {
                        message: 'From date is required'
                    },
                    date: {
                        format: 'MM/DD/YYYY',
                        message: 'The value is not a valid date'
                    },
                    remote: {
                    url: '/assets/cfc/exchange/exchangeintra.cfc?method=checkAvailabilityofDates',
                    type: 'POST',
                    dataType:'json',

                    data: function(validator, $field, value) {
                            return {
                                startDate:0,
                                selectedDate: validator.getFieldElements('bfromDate').val(),
                                bannerId: validator.getFieldElements('bannerId').val(),
                                endRangeFlag:0,
                            };
                        },

                  } 

                },
                onSuccess: function(e, data) {
                   $( "#btoDate" ).prop( "disabled", false ); 

                },
                 onError: function(e, data) {
                     $( "#btoDate" ).val('');
                   $( "#btoDate" ).prop( "disabled", true ); 
                }
          }