.converter-container { max-width: 500px; margin: 2rem auto; padding: 2rem; background: #f9f9f9; border-radius: 15px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); font-family: 'Segoe UI', sans-serif; } .converter-container h2 { text-align: center; color: #2c3e50; margin-bottom: 1rem; } .converter-container input { width: 100%; padding: 0.75rem; font-size: 1rem; border-radius: 8px; border: 1px solid #ccc; margin-bottom: 1rem; box-sizing: border-box; } .converter-container button { width: 100%; padding: 0.75rem; background-color: #0073aa; color: white; font-size: 1rem; border: none; border-radius: 8px; cursor: pointer; transition: background 0.3s ease; } .converter-container button:hover { background-color: #005c8a; } .converter-container .output { margin-top: 1.5rem; font-weight: bold; color: #34495e; background: #e8f4ff; padding: 1rem; border-radius: 10px; } Number to Words Converter (Indian Format) Convert function convertNumberToWords() { const number = document.getElementById("numberInput").value; const output = document.getElementById("wordsOutput"); if (!number || isNaN(number)) { output.innerText = "Please enter a valid number."; return; } const words = numberToWordsIndian(Number(number)); output.innerText = words; } function numberToWordsIndian(number) { const a = [ '', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen' ]; const b = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']; if (number === 0) return 'Rs Zero'; function inWords(num) { if (num < 20) return a[num]; if (num < 100) return b[Math.floor(num / 10)] + (num % 10 !== 0 ? ' ' + a[num % 10] : ''); if (num < 1000) return a[Math.floor(num / 100)] + ' Hundred' + (num % 100 !== 0 ? ' and ' + inWords(num % 100) : ''); if (num < 100000) return inWords(Math.floor(num / 1000)) + ' Thousand' + (num % 1000 !== 0 ? ' ' + inWords(num % 1000) : ''); if (num < 10000000) return inWords(Math.floor(num / 100000)) + ' Lakh' + (num % 100000 !== 0 ? ' ' + inWords(num % 100000) : ''); return inWords(Math.floor(num / 10000000)) + ' Crore' + (num % 10000000 !== 0 ? ' ' + inWords(num % 10000000) : ''); } return 'Rs ' + inWords(number); }