I want a Javascript code which convert input integer to money format.
ex: say my input is 20 it should show me 20.00. If my input is 20.45,it should shoe me the same value as 20.45.
Javascript code which convert input integer to money format
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Paresh Desai4 reputationPosted Jun 4, 2008, 12:20 AM EDT
HTML Syntext
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jun 4, 2008, 12:50 AM EDT
Try it:
function formatAsMoney(ObjVal)
{
//Obj.value = formatAsMny(Obj.value)
mnt = ObjVal;
mnt -= 0;
mnt = (Math.round(mnt*100))/100;
ObjVal = (mnt == Math.floor(mnt)) ? mnt + '.00' : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);
if (isNaN(ObjVal)) {ObjVal ="0.00";}
return ObjVal;
}