Remove Input field 00 after decimal - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Remove Input field 00 after decimal

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w  ww  . ja v a 2s  .  c o m
var val = "1,231,231,232,234.";
var s = parseFloat(val.replace(/,/g,'')).toFixed(2);
while (/\d{4}/.test(s)) {
  s = s.replace(/(\d{3}[,.])/,',$1');
}
console.log(s);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials