Regarding the new Client-side Custom JavaScript Validation function, I have a question.
I have the following code in the
inspection-dv,js
with an AJAX to get the duplicate count (check for any duplicate).
Code: Select all
// >> Custom Validation Scripts
function inspection_customValidateData(insertMode) {
// check if similar pier already inserted in this inspection series
var pier_id = parseInt($j("#pier_id").val());
var inspection_series_id = parseInt($j("#inspection_series_id").val());
if (inspection_series_id) {
$j.ajax({
url: 'hooks/ajax-check_duplicate_inspection_in_series.php',
dataType: "json",
async: false,
data: {
pier_id: pier_id,
inspection_series_id: inspection_series_id,
},
success: function (data) {
console.log(data[0]);
if (data[0] > 0) {
console.log('Hello World');
return false;
}
},
});
}
// if all is ok, return true to proceed
return true;
};
Hello World
in console, but the return false
seems not working as it proceed saving the record.Can someone help me on this?
Thanks.