SharePoint
Friday, November 20, 2015
Pad a number with leading zeros in JavaScript or Jquery
var v = pad(10,4); output as 0010
function pad(n, width, z)
{
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment