I have managed to resolve this with custom JS.
Here is the process, maybe one day someone will need it...
In Designer, I have created three file upload element with next:
- Names: file_1, file_2 and file_3
- Classes: files (same class for all three files upload elements)
- ID's: file_1, file_2 and file_3
On Submit action I have added onclick action with next code:
onclick=checkDuplicates(event)
After submit button element I have added custom code element with three JS:
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script >
$('#file_1, #file_2, #file_3').change(function (e) {
if ($('#file_1').val() != '' && $('#file_1').val() == $('#file_2').val() != '' && $('#file_2').val() || $('#file_1').val() != '' && $('#file_1').val() == $('#file_3').val() != '' && $('#file_3').val() || $('#file_2').val() != '' && $('#file_2').val() == $('#file_3').val() != '' && $('#file_3').val())
{
alert("You can not send two or more same files.");
}
});
</script>
<script type="text/javascript">
checkDuplicates = function(e){
var arr = ;
var fileInputs = document.querySelectorAll(".files");
fileInputs.forEach(function(input){
if(arr.length == 0){
arr.push(input.files[0].name);
} else {
if(arr.indexOf(input.files[0].name) > -1){
e.preventDefault();
alert("You can not send two or more same files.");
} else {
arr.push(input.files[0].name);
}
}
});
};
</script>
That's is.
Here how it works:
There is two validations: First validation will be triggered instantly during file selection, when duplicated file is selected. This validation will be a warning for user that two same files are selected. In case that user ignores the first validation, second validation will be triggered at submit action. User will not be able to submit files as long as he does not remove duplicated file(s).