Feedback on: irt.org FAQ Knowledge Base Q6
Worth:
Very worth reading
Length:
Just right
Comments:
What if the user puts in too many decimal points? the way to get round this is to add
if (test1.length > 2)//check they are not entering loads of decimal points!
{
return false;
}
after you split the string and check the length is == 2.....
this might help!!
Thanks
Worth:
Very worth reading
Length:
Just right
Comments:
Thanks for the help, just right
Worth:
Worth reading
Length:
Too long
Technical:
Too technical
Comments:
A far easier method is to simply use the toFixed method.
<script type="text/javascript">
var money = 100.50;
document.write(money.toFixed(2));
</script>
The above script will display the variable "money" with a fixed decimal point 2 away, displaying the number 100.50. If you give a toFixed value of 4 instead, the displayed number would be 100.5000.