Tuesday, February 28, 2012

zerofill - How can I create a Zerofilled value using JavaScript? - Stack Overflow

zerofill - How can I create a Zerofilled value using JavaScript? - Stack Overflow: "function zeroFill( number, width )
{
  width -= number.toString().length;
  if ( width > 0 )
  {
    return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
  }
  return number;
}"

'via Blog this'