mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
oninvalid event is added to common drag and drop component
This commit is contained in:
parent
40bab7f3b2
commit
966803d3a3
@ -232,7 +232,7 @@
|
||||
th:name="${name}+'-input'" th:id="${name}+'-input-container'" th:data-text="#{fileChooser.hoveredDragAndDrop}">
|
||||
<label class="file-input-btn d-none">
|
||||
<input type="file" class="form-control" th:name="${name}" th:id="${name}+'-input'" th:accept="${accept} + ',.zip'"
|
||||
th:attr="multiple=${!disableMultipleFiles}" th:required="${notRequired} ? null : 'required'">
|
||||
th:attr="multiple=${!disableMultipleFiles}" th:required="${notRequired} ? null : 'required'" oninvalid="alert('Please select a PDF file before submitting.');">
|
||||
Browse
|
||||
</label>
|
||||
<div class="d-flex justify-content-start align-items-center" id="fileInputText">
|
||||
|
@ -28,7 +28,7 @@
|
||||
<span class="tool-header-text" th:text="#{AddStampRequest.header}"></span>
|
||||
</div>
|
||||
<form id="stampFormGroup" method="post" enctype="multipart/form-data" th:action="@{'/api/v1/misc/add-stamp'}">
|
||||
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf', notRequired=true)}"></div>
|
||||
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}"></div>
|
||||
<br>
|
||||
<div class="mb-3">
|
||||
<label for="pageOrder" th:text="#{pageSelectionPrompt}"></label>
|
||||
@ -194,22 +194,6 @@
|
||||
alphabetGroup.style.display = 'none';
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const form = document.getElementById('stampFormGroup');
|
||||
if (form) {
|
||||
form.addEventListener('submit', function(event) {
|
||||
const fileInput = document.getElementById('fileInput-input');
|
||||
if (!fileInput || fileInput.files.length === 0) {
|
||||
// Prevent the form from submitting
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
alert('Please select a PDF file before submitting.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
||||
|
Loading…
Reference in New Issue
Block a user