From e0810022f830195fe2921fd10b14132a45569fa2 Mon Sep 17 00:00:00 2001 From: josephwhite <22449090+josephwhite@users.noreply.github.com> Date: Sat, 9 May 2026 10:51:56 -0400 Subject: [PATCH] WebHost: Fix adding weighted text options (#5116) --- WebHostLib/static/assets/weightedOptions.js | 22 +++++++++++++++---- .../templates/weightedOptions/macros.html | 12 +++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/WebHostLib/static/assets/weightedOptions.js b/WebHostLib/static/assets/weightedOptions.js index 0417ab174b..4aa99963d5 100644 --- a/WebHostLib/static/assets/weightedOptions.js +++ b/WebHostLib/static/assets/weightedOptions.js @@ -123,12 +123,26 @@ window.addEventListener('load', () => { }); const addRangeRow = (optionName) => { - const inputQuery = `input[type=number][data-option="${optionName}"].range-option-value`; + const inputQuery = `input[data-option="${optionName}"]`; const inputTarget = document.querySelector(inputQuery); const newValue = inputTarget.value; - if (!/^-?\d+$/.test(newValue)) { - alert('Range values must be a positive or negative integer!'); - return; + switch (inputTarget.type) { + case 'number': + if (!/^-?\d+$/.test(newValue)) { + alert('Range values must be a positive or negative integer!'); + return; + } + break; + case 'text': + if (newValue === "") { + alert('Range values for text must be a non-empty string!'); + return; + } + break; + default: + console.error(`Found unsupported input type: ${inputTarget.type}`); + return; + break; } inputTarget.value = ''; const tBody = document.querySelector(`table[data-option="${optionName}"].range-rows tbody`); diff --git a/WebHostLib/templates/weightedOptions/macros.html b/WebHostLib/templates/weightedOptions/macros.html index 1d485a24de..0c20992973 100644 --- a/WebHostLib/templates/weightedOptions/macros.html +++ b/WebHostLib/templates/weightedOptions/macros.html @@ -71,10 +71,10 @@