Archive for the 'Programming' Category

JavaScript parseMoney

Thursday, March 31st, 2005

In order to change the input number format to currency format, e.g. 12500 => 12,500. The javascript code I write as follows: keratin hair treatment formaldehyde

function parseMoney(objID) {
var obj = document.all[objID]; //get the object
if(obj.value=='’) {
return; //do no job when the value is empty
}
//check number format
var […]

JavaScript Trim

Sunday, March 27th, 2005

JavaScript does not support trim function which VBScript does. Here is the implementation of trim function in JavaScript simply using regular expression.
function trim(str) {
return str.replace(/^\s*|\s*$/g,”");
}