Category Archives: JavaScript

Showing the Processing/Loading image

I came across a good code sample while surfing for showing the Loading/Processing  image on the VisualForce Page.

You can find it at:

Regex for AlphaNumeric password validation

Regular Expression for validating the string


The above RegEx requires at least one digit, at least one alphabetic character, no special characters, and from 8-20 characters in length.

JavaScript: Number to Currency format conversion function

JavaScript for converting string to currency format.

function FormatToCurrency(num)
num = num.toString().replace(/\$|\,/g,'');
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents < 10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);