Script :
<script type="text/javascript">
function formatangka()
{
a = form1.harga.value;
b = a.replace(/[^\d]/g,"");
c = "";
panjang = b.length;
j = 0;
for (i = panjang; i > 0; i--)
{
j = j + 1;
if (((j % 3) == 1) && (j != 1))
{
c = b.substr(i-1,1) + "," + c;
} else {
c = b.substr(i-1,1) + c;
}
}
form1.harga.value = c;
}
</script>
<br/>
<p>Format Angka Pada Input Text</p>
<br/>
<form name="form1">
<input type="text" name="harga" onkeyup="formatangka()">
</form>
No comments:
Post a Comment