Is there a way we can customize remote validation like a normal 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'
}
}
}
}
});
When remote validation success than do any other things,if failed than do another things.
I have got the following link: http://formvalidation.io/examples/using-data-returned-validator/
But it is work,only if i am using formvalidation but here i am using bootstrapValidator.so is there any way to do the same like formvalidation.
After field validation gets completed, it calls onSuccess or onError callback. Below is the sample code that resolve my issue:
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 );
}
}