<html> <script type="text/javascript"> <!-- function numberFormat(num){ return String(num).replace(/(-?\d*)(?!\d)/, function(intPart){ return intPart.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"); }); } //--> </script> <body> <input type="button" value="click" onclick="alert(numberFormat(-10000000.000001))"> </body> </html>