// Licensed Materials - Property of IBM // // IBM Cognos Products: pps // // (C) Copyright IBM Corp. 2005, 2017 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // Number Utilities function CNumUtil() {}; CNumUtil.normalizeDecimal = function (str) { if ( decimalpt != "." ) { var reg = new RegExp(decimalpt, "g"); str = str.replace(reg, "."); } return str; } CNumUtil.validateNumField = function (FormObj, acceptDecimal, validChars) { var userInput = FormObj.value; var reducedInput = ""; var len = userInput.length; for ( var i = 0; i < len; i++ ) { //Strip out the thousand Separators. if (userInput.charAt(i) != thousandsep) { reducedInput += userInput.charAt(i); } } FormObj.value = reducedInput; //check for invalid characters if valid range was specified!!! if( !(typeof validChars == "undefined") && validChars != null && validChars.length > 0 && reducedInput.length > 0 ) { var pos; pos = reducedInput.search(eval(validChars)); if (pos != -1) return false; } var nInput = Number(this.normalizeDecimal(reducedInput)); if(isNaN(nInput)) return false; if(!acceptDecimal && (Math.ceil(nInput) != nInput)) return false; return true; } CNumUtil.localizeDecimal = function(str) { if ( decimalpt != "." ) { str = str.replace( ".", decimalpt ); } return str; }