From 40bab7f3b224e19e398a4316dcae6ac0149f6f53 Mon Sep 17 00:00:00 2001 From: saikumarjetti Date: Sun, 16 Mar 2025 23:51:13 +0530 Subject: [PATCH] alert if input file is not selected for stamp --- .../controller/api/misc/StampController.java | 4 -- src/main/resources/templates/misc/stamp.html | 37 ++++++++----------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java index 59bfe6286..e23635b82 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java @@ -73,10 +73,6 @@ public class StampController { int position = request.getPosition(); // Updated to use 1-9 positioning logic float overrideX = request.getOverrideX(); // New field for X override float overrideY = request.getOverrideY(); // New field for Y override - // Check if the file input is null or empty - if (request.getFileInput() == null || request.getFileInput().isEmpty()) { - return ResponseEntity.badRequest().body("PDF file is missing.".getBytes()); - } String customColor = request.getCustomColor(); float marginFactor; diff --git a/src/main/resources/templates/misc/stamp.html b/src/main/resources/templates/misc/stamp.html index b2091a4c8..8b4756842 100644 --- a/src/main/resources/templates/misc/stamp.html +++ b/src/main/resources/templates/misc/stamp.html @@ -194,29 +194,22 @@ alphabetGroup.style.display = 'none'; } } - document.addEventListener('DOMContentLoaded', function() { - // Get the form by ID - const form = document.getElementById('stampFormGroup'); - if (form) { - // Override the default submission behavior - form.addEventListener('submit', function(event) { - // Get the file input element (using the pattern from the fileSelector fragment) - const fileInput = document.getElementById('fileInput-input'); - // Check if files are selected - if (!fileInput || fileInput.files.length === 0) { - // Prevent the form from submitting - event.preventDefault(); - event.stopPropagation(); - - // Alert the user - alert('Please select a PDF file before submitting.'); - return false; + 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); } - return true; - }, true); - } - }); - + });