checkbox can't be unselected

This commit is contained in:
counterweight 2025-02-25 00:52:25 +01:00
parent d308d2f26d
commit fad4e7a174
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 13 additions and 18 deletions

View file

@ -1,5 +1,5 @@
* { * {
font-family: 'Courier New', Courier, monospace; font-family: Arial, Helvetica, sans-serif;
box-sizing: border-box; box-sizing: border-box;
} }

View file

@ -29,6 +29,8 @@ const btcMethodCheckboxesWarning = document.getElementById(
const btcMethodCheckboxes = [onchainCheckbox, lightningCheckbox]; const btcMethodCheckboxes = [onchainCheckbox, lightningCheckbox];
const publishOfferButton = document.getElementById('button-submit-offer');
function toggleCreateOfferControls() { function toggleCreateOfferControls() {
createOfferControls.style.display = createOfferControls.style.display =
createOfferControls.style.display === 'block' ? 'none' : 'block'; createOfferControls.style.display === 'block' ? 'none' : 'block';
@ -92,19 +94,10 @@ function updateBtcInput() {
btcAmountInput.value = formattedSatsAmount; btcAmountInput.value = formattedSatsAmount;
} }
function validateBitcoinMethodCheckboxes() { function validateBitcoinMethodCheckboxes(clickedCheckbox) {
let noneChecked = true; let checkedCount = btcMethodCheckboxes.filter((cb) => cb.checked).length;
if (checkedCount === 0) {
for (const aCheckbox of btcMethodCheckboxes) { clickedCheckbox.checked = true;
if (aCheckbox.checked) {
noneChecked = false;
}
}
if (noneChecked) {
btcMethodCheckboxesWarning.style.display = 'block';
} else {
btcMethodCheckboxesWarning.style.display = 'none';
} }
} }
@ -141,7 +134,9 @@ eurAmountInput.addEventListener('input', () => {
}); });
for (const btcMethodCheckbox of btcMethodCheckboxes) { for (const btcMethodCheckbox of btcMethodCheckboxes) {
btcMethodCheckbox.addEventListener('input', () => { btcMethodCheckbox.addEventListener('click', () => {
validateBitcoinMethodCheckboxes(); validateBitcoinMethodCheckboxes(btcMethodCheckbox);
}); });
} }
updateBtcInput();

View file

@ -70,7 +70,7 @@
id="input-eur-amount" id="input-eur-amount"
type="text" type="text"
class="money-input input-money-amount" class="money-input input-money-amount"
placeholder="100" value="100"
required required
/> />
<div id="eur-symbol" class="curr-symbol"> <div id="eur-symbol" class="curr-symbol">
@ -162,7 +162,7 @@
</div> </div>
<%- include("partials/appCommonScripts") %> <%- include("partials/appCommonScripts") %>
<script src="/javascript/offers.js"></script>
<script src="/javascript/utils.js"></script> <script src="/javascript/utils.js"></script>
<script src="/javascript/offers.js"></script>
</body> </body>
</html> </html>