From 63ddae57aab29577ea844b43305b1c4692c1278f Mon Sep 17 00:00:00 2001 From: "Joanne.Chuang" Date: Wed, 14 Jan 2026 20:26:17 +0800 Subject: [PATCH] =?UTF-8?q?Client=E9=A9=97=E8=AD=89=E5=9B=9B=E9=A0=85?= =?UTF-8?q?=E6=93=87=E4=B8=80=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Altob.NtuInvoiceGateway/Pages/Invoice.cshtml | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Altob.NtuInvoiceGateway/Pages/Invoice.cshtml b/Altob.NtuInvoiceGateway/Pages/Invoice.cshtml index 46be77f..1abf25d 100644 --- a/Altob.NtuInvoiceGateway/Pages/Invoice.cshtml +++ b/Altob.NtuInvoiceGateway/Pages/Invoice.cshtml @@ -176,6 +176,15 @@ const successAlert = document.getElementById('formSuccessMessage'); const submitButtonContainer = document.getElementById('submitButtonContainer'); + const showError = (message) => { + if (!errorAlert || !errorText) { + alert(message); + return; + } + errorText.textContent = message; + errorAlert.classList.remove('d-none'); + }; + const hideError = () => { if (!errorAlert || !errorText) { return; @@ -186,6 +195,13 @@ errorCloseBtn?.addEventListener('click', hideError); + const optionalGroup = [ + document.querySelector('input[name="InvoiceData.Email"]'), + document.querySelector('input[name="InvoiceData.CarrierID"]'), + document.querySelector('input[name="InvoiceData.BuyerIdentifier"]'), + document.querySelector('select[name="InvoiceData.LoveCode"]') + ]; + const form = document.querySelector('form[method="post"]'); if (!form) { return; @@ -218,6 +234,19 @@ return; } + const filledCount = optionalGroup.reduce((count, field) => { + if (field && field.value.trim() !== '') { + return count + 1; + } + return count; + }, 0); + + if (filledCount === 0) { + event.preventDefault(); + showError('Email、手機條碼、購買者統編、捐贈碼需擇一填寫,請填寫任一項。'); + return; + } + hideError(); lockForm(); });