有没有一种方法可以像普通的 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'
}
}
}
}
});
当远程验证成功时比做任何其他事情,如果失败比做其他事情。
我有以下链接: http: //formvalidation.io/examples/using-data-returned-validator/
但它是有效的,只有当我使用 formvalidation 但在这里我使用 bootstrapValidator.so 有没有办法像 formvalidation 一样做同样的事情。