Javascript String padNum(amount)
String.prototype.padNum = function(amount) { var length = this.length; var newString = ''; for (var i=0; i<amount-length; i++) { newString += '0'; }/*from w ww. ja v a 2 s .c o m*/ newString += this; return newString; }