Decimal Zeros At The End Are Not Show. Anyone Help Me Please
alert(10.1000); I need to show the 3 zeros at the end after decimal point. The last 3 zeros are cleared by default.
Solution 1:
You can use the javaScripts .toFixed(n) method where n
refers to the number of Decimals.
alert(10.1000.toFixed(4));
For arbitrary inputs you can try this way,
HTML :
<inputtype="number"id="inputTextbox" />
javaScript :
inputTextbox.onblur = function(){
ShowNumber(this.value);
};
functionShowNumber(num){
var decimalNumLength = num.split('.')[1].length;
alert(Number(num).toFixed(decimalNumLength));
}
Post a Comment for "Decimal Zeros At The End Are Not Show. Anyone Help Me Please"