This function below return true/false. How I could possibly improve the code quality?
function uploadcontrolhasError() {
if (dialogisVisible === true) {
let uploadcontrol = $("#upImport").data("kendoUpload"),
files = uploadcontrol.getFiles();
console.log(files);
let FileLink = $("#txtFileLink").val();
if (files.length === 0 || FileLink.length != 0) {
let dialogcontrol = $('#Dialog').data("kendoDialog");
dialogcontrol.open();
return true;
} else {
processuploadControl();
return false;
}
} else {
processuploadControl();
return false
}
}
function processuploadControl() {
let uploadcontrol = $("#upImport").data("kendoUpload"),
files = uploadcontrol.getFiles();
if (files.length != 0) {
var counter = 0;
$('.k-file-success[data-fileManagerIds]').each(function (kfile) {
let filemanagerid = this.dataset.filemanagerids;
let hdfilemanagerid = $('<input>').attr({
type: 'hidden',
name: 'fileManagerIds[' + counter + ']',
id: 'fileManagerIds',
value: filemanagerid
});
$("#permissionsRequestForm").append(hdfilemanagerid);
counter++;
});
}
}
function processsubmitForm() {
dialogisVisible = false;
var dialog = $("#Dialog").data("kendoDialog");
dialog.close();
$("#permissionsRequestForm").submit();
}
function closeDialog() {
dialogisVisible = false;
var dialog = $("#Dialog").data("kendoDialog");
dialog.close();
}
function materialsconfirmhasError() {
let materialsconfirm = $('input[name="ckmaterialsconfirm"]:checked').length > 0;
let uploadcontrol = $("#upImport").data("kendoUpload"),
files = uploadcontrol.getFiles();
let FileLink = $("#txtFileLink").val();
console.log(FileLink);
if (files.length != 0 || FileLink.length != 0) {
if (materialsconfirm == false) {
$("#lblConfirmError").show();
return true
} else {
$("#lblConfirmError").hide();
return false
}
}
return false
}
function uploadcontrolsizehasError() {
var hasError = false;
$('.k-file-name-invalid').each(function (kfile) {
console.log('uploadcontrolsizehasError');
$("#lblFileSizeError").show();
hasError = true;
});
return hasError;
}