From cc6771ba07b65983e8765a8440a4b2669e3862d4 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 19 Oct 2025 09:21:37 -0700 Subject: [PATCH] Add required attribute to bridged form inputs --- app/js/ui/main.js | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/app/js/ui/main.js b/app/js/ui/main.js index dc623236..e4abdba1 100644 --- a/app/js/ui/main.js +++ b/app/js/ui/main.js @@ -82,32 +82,23 @@ document.addEventListener('DOMContentLoaded', function() { const bridgeCheckbox = document.getElementById('chxbridgedenable'); const bridgeSection = document.getElementById('bridgeStaticIpSection'); const staticIpInput = document.getElementById('bridgeStaticIp'); + const netmaskInput = document.getElementById('bridgeNetmask'); + const gatewayInput = document.getElementById('bridgeGateway'); + const dnsInput = document.getElementById('bridgeDNS'); const previewIp = document.getElementById('previewStaticIp'); - // toggle visibility + const bridgeInputs = [staticIpInput, netmaskInput, gatewayInput, dnsInput]; + + // toggle visibility and required fields bridgeCheckbox.addEventListener('change', function() { - bridgeSection.style.display = this.checked ? 'block' : 'none'; + if (this.checked) { + bridgeSection.style.display = 'block'; + bridgeInputs.forEach(input => input.setAttribute('required', 'required')); + } else { + bridgeSection.style.display = 'none'; + bridgeInputs.forEach(input => input.removeAttribute('required')); + } }); - - staticIpInput.addEventListener('input', function() { - previewIp.textContent = this.value || 'your-static-ip'; - }); - - const form = bridgeCheckbox.closest('form'); - if (form) { - form.addEventListener('submit', function(e) { - if (bridgeCheckbox.checked) { - const staticIp = staticIpInput.value.trim(); - const gateway = document.getElementById('bridgeGateway').value.trim(); - - if (staticIp && !gateway) { - e.preventDefault(); - // raise alert - return false; - } - } - }); - } }); /**