function Trim(string) { return string.replace(/\s*/g, ""); } function LTrim(string) { return string.replace(/(^\s*)/g, ""); } function RTrim(string) { return string.replace(/(\s*$)/g, ""); } function checkForInt(elem, show_error) { try { var temp_t = elem.value; temp_t = temp_t.replace(/\s*/g, ""); if (isNum(temp_t)) { elem.value = temp_t; return 1; } else { if (show_error == 1) { alert('Supplied position: ' + text + ' is numeric'); } return 0; } } catch(e) { // retrun 0; } } function isNum(string) { var nums = "0123456789"; var numeric=true; var char; for (var i = 0; numeric == true && i < string.length; ++i) { char = string.charAt(i); if (nums.indexOf(char) == -1) { numeric= false; } } return numeric; }