showing results for - "how to convert entered number into currency in words in javascript"
Muhammad
16 Jul 2016
1var a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
2var b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety'];
3
4function inWords (num) {
5    if ((num = num.toString()).length > 9) return 'overflow';
6    n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
7    if (!n) return; var str = '';
8    str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + ' ' + a[n[1][1]]) + 'crore ' : '';
9    str += (n[2] != 0) ? (a[Number(n[2])] || b[n[2][0]] + ' ' + a[n[2][1]]) + 'lakh ' : '';
10    str += (n[3] != 0) ? (a[Number(n[3])] || b[n[3][0]] + ' ' + a[n[3][1]]) + 'thousand ' : '';
11    str += (n[4] != 0) ? (a[Number(n[4])] || b[n[4][0]] + ' ' + a[n[4][1]]) + 'hundred ' : '';
12    str += (n[5] != 0) ? ((str != '') ? 'and ' : '') + (a[Number(n[5])] || b[n[5][0]] + ' ' + a[n[5][1]]) + 'only ' : '';
13    return str;
14}
15
16document.getElementById('number').onkeyup = function () {
17    document.getElementById('words').innerHTML = inWords(document.getElementById('number').value);
18};
queries leading to this page
js number to words currencyconvert number to words in javascriptconvert amount in words javascripthow to convert number to currency in javascriptshow specific number of words javascriptnumber of words javascriptwords to number in reactjavascript code to convert numeric numbers into wordsjavascript convert number to wordsjavascript convert amount to wordsnumber to words indian currency javascriptdisplay number in words in javascriptnumber to word javascriptnumber to words javascriptnumbers to words converter using jsextract number out of currency string javascriptjavascript phone numbers to wordsamount in indian words javascriptjavascript function convert number to currencyjavascript single digit to word number to word converter javascript codeconvert indian currency numbers to words in javascriptcurrency to words jsjavascript currency to numbernumber to word jsjavascript currency format to numberjavascript digit to wordconvert number to words javascripthow to convert entered number into currency in words in javascriptamount in words javascriptconvert number to currency in javascriptjs currency to wordsnumber in words jsjavascript number o wordscurrency to words javascriptjavascript convert number to currencyjavascript to convert number to currencyamount to word currency javascriptconvert numeric value into words 28currency 29 in jsamount in words dollar in javascriptamount to words javascriptjavascript to get number in wordshow to convert entered number into currency in words in javascript