Bhagwat Singh

PHP Developer Portfolio


Pad a number with leading zeroes in Javascript

As far as I know there isn’t a in-built way with Javascript to pad a number with leading zeroes to make it a fixed width like str_pad in PHP programming language. This post looks at a way to pad a number with zeroes with Javascript.

function pad(iNumber, iLength)
var sOutputStr= ” + iNumber;
while (sOutputStr.length < iLength) { sOutputStr = '0' + sOutputStr; } return sOutputStr; }

Parent Page Refresh Through Javascript

There are many ways to refresh the parent page from the sub-window(modal window) through javascript. Some of them are:



URL Validation In Javascript

function isUrl(url)
var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return RegexUrl.test(url);

Site Nevigation