Numbers to words Converter
Javascript converter that converts the entered numbers into words/text.
Features
- Simple javascript converter that converts currency into words.
- Type the number in the box and then click "Convert"
- Enter only the whole number. Do not type a decimal point or comma.
Preview
Downloads
Javascript
<!-- Script by hscripts.com -->
<script type="text/javascript">
var nume=document.getElementById('num').value;function isNumeric(){var elem=document.niw.num.value;if(elem!="") {var numericExpression = /^[0-9]+$/;if(elem.match(numericExpression)){return true;
}else{alert("Please Enter Only Number ");document.niw.num.value="";
return false;}}
}
function numinwrd(){var numbr=document.getElementById('num').value;var str=new String(numbr)
var splt=str.split("");var rev=splt.reverse();var once=['Zero', ' One', 'Two', 'Three', 'Four',
'Five', 'Six', 'Seven', 'Eight', 'Nine'];var twos=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];var tens=[ '', 'Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];numlen=rev.length;var word=new Array();var j=0;
for(i=0;i<numlen;i++){switch(i){case 0:if((rev[i]==0) || (rev[i+1]==1)){word[j]='';
}else{word[j]=once[rev[i]];}word[j]=word[j] ;break;case 1:abovetens();
break;case 2:if(rev[i]==0){word[j]='';} else if((rev[i-1]==0) || (rev[i-2]==0) ){word[j]=once[rev[i]]+"Hundred ";
}else {word[j]=once[rev[i]]+"Hundred and";} break;case 3:if(rev[i]==0 || rev[i+1]==1){word[j]='';
} else{word[j]=once[rev[i]];}if((rev[i+1]!=0) || (rev[i] > 0)){word[j]= word[j]+" Thousand";}break;
case 4:abovetens(); break;
case 5:if((rev[i]==0) || (rev[i+1]==1)){word[j]='';
} else{word[j]=once[rev[i]];}word[j]=word[j]+"Lakhs";break;
case 6:abovetens(); break;case 7:if((rev[i]==0) || (rev[i+1]==1)){word[j]='';
} else{word[j]=once[rev[i]];}word[j]= word[j]+"Crore";break;
case 8:abovetens(); break;
default:break;}j++;
} function abovetens()
{if(rev[i]==0){word[j]='';} else if(rev[i]==1){word[j]=twos[rev[i-1]];}else{word[j]=tens[rev[i]];}
}
word.reverse();
var finalw='';
for(i=0;i<numlen;i++)
{finalw= finalw+word[i];
}
document.getElementById('number').innerHTML=finalw;
}
function ctck()
{var sds = document.getElementById("dum");if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}var sdss = document.getElementById("dumdiv");if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}
document.onload ="ctck()";
</script><!-- Script by hscripts.com -->
HTML Code
<!-- Script by hscripts.com -->
<form name="niw">
<table align=center
width=100% style="font-size: 12px; display: block;">
<tr><td>
<table
width=100% style="font-family: Monaco, Verdana, Sans-serif; font-size: 12px;
display: block;
margin-top: 14px;padding: 12px 20px 12px 20px;">
<tr>
<td>
Number:<input type="text" name="num" id="num" maxlength=9 onKeyup="isNumeric()">
<input type="button" name="sr1" value="Click Here" onClick="numinwrd()">
</td></tr>
<tr><td><div id="number"></div></td></tr>
</table></td></tr></table>
</form>
<div style="font-size: 10px;color: #dadada;" id="dumdiv" align=center>
<a href="https://www.hscripts.com" id="dum" style="text-decoration:none;color: #dadada;">©h</a></div>
- Release Date - 21-12-2010
- Get free version without ©copyright link for just $10/-
- For customization of this script or any script development, mail to support@hscripts.com
Usage
- Copy and paste the javascript code into your file.
- Follow the instructions given in the readme file.
- Simple and easy to use numbers to words converter.
License
Related Scripts