at least one checkbox
This commit is contained in:
parent
940b833418
commit
c4155b0b5d
2 changed files with 43 additions and 3 deletions
|
|
@ -21,6 +21,14 @@ const buttonDecreasePremium = document.getElementById(
|
|||
const eurAmountInput = document.getElementById('input-eur-amount');
|
||||
const btcAmountInput = document.getElementById('input-btc-amount');
|
||||
|
||||
const onchainCheckbox = document.getElementById('onchain-checkbox');
|
||||
const lightningCheckbox = document.getElementById('lightning-checkbox');
|
||||
const btcMethodCheckboxesWarning = document.getElementById(
|
||||
'at-least-one-checkbox'
|
||||
);
|
||||
|
||||
const btcMethodCheckboxes = [onchainCheckbox, lightningCheckbox];
|
||||
|
||||
function toggleCreateOfferControls() {
|
||||
createOfferControls.style.display =
|
||||
createOfferControls.style.display === 'block' ? 'none' : 'block';
|
||||
|
|
@ -82,6 +90,22 @@ function updateBtcInput() {
|
|||
btcAmountInput.value = formattedSatsAmount;
|
||||
}
|
||||
|
||||
function validateBitcoinMethodCheckboxes() {
|
||||
let noneChecked = true;
|
||||
|
||||
for (const aCheckbox of btcMethodCheckboxes) {
|
||||
if (aCheckbox.checked) {
|
||||
noneChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (noneChecked) {
|
||||
btcMethodCheckboxesWarning.style.display = 'block';
|
||||
} else {
|
||||
btcMethodCheckboxesWarning.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
buttonStartCreateOffer.addEventListener('click', () => {
|
||||
toggleCreateOfferControls();
|
||||
});
|
||||
|
|
@ -112,3 +136,9 @@ eurAmountInput.addEventListener('blur', () => {
|
|||
eurAmountInput.addEventListener('input', () => {
|
||||
eurAmountInput.value = eurAmountInput.value.replace(/[^0-9]/g, '');
|
||||
});
|
||||
|
||||
for (btcMethodCheckbox of btcMethodCheckboxes) {
|
||||
btcMethodCheckbox.addEventListener('input', () => {
|
||||
validateBitcoinMethodCheckboxes();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue