mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
invalid event listener is added to file input
This commit is contained in:
parent
3ec2817485
commit
5938e18e2e
@ -36,6 +36,7 @@ function setupFileInput(chooser) {
|
|||||||
const inputContainerId = chooser.getAttribute('data-bs-element-container-id');
|
const inputContainerId = chooser.getAttribute('data-bs-element-container-id');
|
||||||
|
|
||||||
let inputContainer = document.getElementById(inputContainerId);
|
let inputContainer = document.getElementById(inputContainerId);
|
||||||
|
let fileInput = document.getElementById(elementId);
|
||||||
|
|
||||||
if (inputContainer.id === 'pdf-upload-input-container') {
|
if (inputContainer.id === 'pdf-upload-input-container') {
|
||||||
inputContainer.querySelector('#dragAndDrop').innerHTML = window.fileInput.dragAndDropPDF;
|
inputContainer.querySelector('#dragAndDrop').innerHTML = window.fileInput.dragAndDropPDF;
|
||||||
@ -51,6 +52,12 @@ function setupFileInput(chooser) {
|
|||||||
inputBtn.click();
|
inputBtn.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle form validation if the input is left empty
|
||||||
|
fileInput.addEventListener("invalid", (e)=>{
|
||||||
|
e.preventDefault();
|
||||||
|
alert('Please select a PDF file before submitting.')
|
||||||
|
});
|
||||||
|
|
||||||
const dragenterListener = function () {
|
const dragenterListener = function () {
|
||||||
dragCounter++;
|
dragCounter++;
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
|
@ -232,7 +232,7 @@
|
|||||||
th:name="${name}+'-input'" th:id="${name}+'-input-container'" th:data-text="#{fileChooser.hoveredDragAndDrop}">
|
th:name="${name}+'-input'" th:id="${name}+'-input-container'" th:data-text="#{fileChooser.hoveredDragAndDrop}">
|
||||||
<label class="file-input-btn d-none">
|
<label class="file-input-btn d-none">
|
||||||
<input type="file" class="form-control" th:name="${name}" th:id="${name}+'-input'" th:accept="${accept} + ',.zip'"
|
<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'" oninvalid="alert('Please select a PDF file before submitting.');">
|
th:attr="multiple=${!disableMultipleFiles}" th:required="${notRequired} ? null : 'required'">
|
||||||
Browse
|
Browse
|
||||||
</label>
|
</label>
|
||||||
<div class="d-flex justify-content-start align-items-center" id="fileInputText">
|
<div class="d-flex justify-content-start align-items-center" id="fileInputText">
|
||||||
|
Loading…
Reference in New Issue
Block a user