var Utils = new Utils_class(); var DEFAULT_ZEROS = 2; var ERROR_COLOR = "pink"; function Utils_class() { var numberASCII = new Array(0,1,2,3,4,5,6,7,8,9); var decimalASCII = new Array(0,1,2,3,4,5,6,7,8,9,DECIMAL_SEPARATOR); this.checkNumberInput = checkNumberInput; this.checkValidChar = checkValidChar; this.decimalCount = decimalCount; this.precise = precise; this.trim = trim; function checkNumberInput() { trimOther(this); var inputValue = this.value; var pickedChars = (this.className=="decimalInput") ? decimalASCII : numberASCII; for(var i=0;i=0 && DECIMAL_SEPARATOR=="," ){ //DO NOT change the hard coded dot var firstPart = roundedValue.substring(0,roundedValue.indexOf(".")); var lastPart = roundedValue.substring(roundedValue.indexOf(".")+1, roundedValue.length); roundedValue = firstPart + DECIMAL_SEPARATOR + lastPart; } //window.status = roundedValue; if(roundedValue.indexOf(DECIMAL_SEPARATOR)==-1) { if(decimalDigits>0){ var zeros = DECIMAL_SEPARATOR; for(var i=0; i=0 && diff<=9) return; } event.keyCode = null; return false; } function decimalCount(decimalValue, occurance) { var decimalCount = 0; for(var i=0;ioccurance) return true; } return false; } function trim() { if(this.disabled==true || this.readOnly==true) return; //var unWantedChars = new RegExp("['|<>\"]"); //original code var unWantedChars = new RegExp("[|<>\"]"); //single quote removed from original code this.value = (this.value.replace(/(\s+)$/,'')).replace(/^(\s+)/,''); if(this.value=="" && this.required=="true" ){ //if blank this.style.backgroundColor = ERROR_COLOR; }else if(unWantedChars.exec(this.value)!=null){ //if contains special chars this.style.backgroundColor = ERROR_COLOR; } else { this.style.backgroundColor = ""; } } function trimOther(whichObject) { if(whichObject.disabled==true || whichObject.readOnly==true){ return; } if(whichObject.required=="true"){ var inputValue = (whichObject.value.replace(/(\s+)$/,'')).replace(/^(\s+)/,''); if(inputValue=="") { whichObject.style.backgroundColor = ERROR_COLOR; }else { whichObject.style.backgroundColor = ""; } } } }