Update script.js
Browse files
script.js
CHANGED
|
@@ -8,6 +8,7 @@ document.getElementById('currencyForm').addEventListener('submit', async functio
|
|
| 8 |
|
| 9 |
if (!amount || amount <= 0) {
|
| 10 |
resultDiv.innerHTML = "Please enter a valid amount!";
|
|
|
|
| 11 |
return;
|
| 12 |
}
|
| 13 |
|
|
@@ -26,17 +27,14 @@ document.getElementById('currencyForm').addEventListener('submit', async functio
|
|
| 26 |
}
|
| 27 |
} catch (error) {
|
| 28 |
resultDiv.innerHTML = "Error fetching conversion rate.";
|
| 29 |
-
console.error(
|
| 30 |
}
|
| 31 |
});
|
| 32 |
|
| 33 |
document.getElementById('swapButton').addEventListener('click', function() {
|
| 34 |
const fromCurrency = document.getElementById('fromCurrency');
|
| 35 |
const toCurrency = document.getElementById('toCurrency');
|
| 36 |
-
|
| 37 |
const temp = fromCurrency.value;
|
| 38 |
fromCurrency.value = toCurrency.value;
|
| 39 |
toCurrency.value = temp;
|
| 40 |
-
|
| 41 |
-
document.getElementById('result').innerHTML = "";
|
| 42 |
});
|
|
|
|
| 8 |
|
| 9 |
if (!amount || amount <= 0) {
|
| 10 |
resultDiv.innerHTML = "Please enter a valid amount!";
|
| 11 |
+
resultDiv.style.color = 'red';
|
| 12 |
return;
|
| 13 |
}
|
| 14 |
|
|
|
|
| 27 |
}
|
| 28 |
} catch (error) {
|
| 29 |
resultDiv.innerHTML = "Error fetching conversion rate.";
|
| 30 |
+
console.error(error);
|
| 31 |
}
|
| 32 |
});
|
| 33 |
|
| 34 |
document.getElementById('swapButton').addEventListener('click', function() {
|
| 35 |
const fromCurrency = document.getElementById('fromCurrency');
|
| 36 |
const toCurrency = document.getElementById('toCurrency');
|
|
|
|
| 37 |
const temp = fromCurrency.value;
|
| 38 |
fromCurrency.value = toCurrency.value;
|
| 39 |
toCurrency.value = temp;
|
|
|
|
|
|
|
| 40 |
});
|