USD to INR Exchange Rate Calculator
This calculator helps you quickly convert United States Dollars (USD) to Indian Rupees (INR) based on the current exchange rate.
function calculateINR() {
var usdAmountInput = document.getElementById("usdAmount");
var exchangeRateInput = document.getElementById("exchangeRate");
var inrResultDisplay = document.getElementById("inrResult");
var usdAmount = parseFloat(usdAmountInput.value);
var exchangeRate = parseFloat(exchangeRateInput.value);
if (isNaN(usdAmount) || isNaN(exchangeRate) || usdAmount < 0 || exchangeRate <= 0) {
inrResultDisplay.textContent = "Please enter valid positive numbers for both amounts.";
return;
}
var inrAmount = usdAmount * exchangeRate;
inrResultDisplay.textContent = usdAmount.toFixed(2) + " USD is equal to " + inrAmount.toFixed(2) + " INR.";
}
.calculator-container {
font-family: sans-serif;
max-width: 400px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
font-size: 0.9em;
color: #555;
margin-bottom: 20px;
text-align: center;
}
.input-section {
margin-bottom: 15px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-section input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
padding-top: 15px;
border-top: 1px solid #eee;
text-align: center;
}
#result h3 {
margin-bottom: 10px;
color: #333;
}
#inrResult {
font-size: 1.1em;
font-weight: bold;
color: #007bff;
}