//JS Functions @0-05D96CAB var isNN = (navigator.appName.indexOf("Netscape") != -1); var isIE = (navigator.appName.indexOf("Microsoft") != -1); var IEVersion = (isIE ? getIEVersion() : 0); var NNVersion = (isNN ? getNNVersion() : 0); var EditableGrid = false; var disableValidation = false; function parseParams(text,substitutions) { // replace the {0}, ... with corresponded substitution string and return the result var resString = text; if (resString!="" && substitutions!=null) { var array = (typeof(substitutions)!="object")?(new Array(substitutions)):substitutions; for (var i=0; i0) return isMajor; } if (userAgent.toLowerCase().indexOf('firefox')!=-1) return 7; return 6; } return isMajor; } function getIEVersion() { var userAgent = window.navigator.userAgent; var MSIEPos = userAgent.indexOf("MSIE"); return (MSIEPos > 0 ? parseInt(userAgent.substring(MSIEPos+5, userAgent.indexOf(".", MSIEPos))) : 0); } function inputMasking(evt) { if (isIE && IEVersion > 4) { if (window.event.altKey) return false; if (window.event.ctrlKey) return false; if (typeof(this.ccsInputMask) == "string") { var mask = this.ccsInputMask; var keycode = window.event.keyCode; this.value = applyMask(keycode, mask, this.value); } return (window.event.keyCode==13?true:false); } else if (isNN && NNVersion<6) { if (evt.ALT_MASK) return false; if (evt.CONTROL_MASK) return false; if (typeof(this.ccsInputMask) == "string") { var mask = this.ccsInputMask; var keycode = evt.which; this.value = applyMask(keycode, mask, this.value); } return (evt.which==13?true:false); } else if (isNN && NNVersion==6) { if (evt.altKey) return false; if (evt.ctrlKey) return false; var cancelKey = evt.which==13; if (typeof(this.ccsInputMask) == "string") { var mask = this.ccsInputMask; var keycode = evt.which; if (keycode >= 32) this.value = applyMaskToValue(mask, this.value); } return cancelKey || evt.which==13; } else if (isNN && NNVersion==7) { if (evt.altKey) return false; if (evt.ctrlKey) return false; var cancelKey = evt.which==13; if (typeof(this.ccsInputMask) == "string") { var mask = this.ccsInputMask; var keycode = evt.which; cancelKey = keycode < 32; if (!cancelKey) this.value = applyMask(keycode, mask, this.value); } return cancelKey || evt.which==13; } else return true; } function applyMaskToValue(mask, value) { var oldValue = String(value); var newValue = ""; for (var i=0; i= 48 && keycode <= 57); var plus = (keycode == 43); var dash = (keycode == 45); var space = (keycode == 32); var uletter = (keycode >= 65 && keycode <= 90); var lletter = (keycode >= 97 && keycode <= 122); var pos = value.length; switch(mask.charAt(pos)) { case "0": if (digit) value += String.fromCharCode(keycode); break; case "L": if (uletter || lletter) value += String.fromCharCode(keycode); break; default: var isMatchMask = (String.fromCharCode(keycode) == mask.charAt(pos)); while (pos < mask.length && mask.charAt(pos) != "0" && mask.charAt(pos) != "L") value += mask.charAt(pos++); if (!isMatchMask && pos < mask.length) value = applyMask(keycode, mask, value); } return value; } function validate_control(control) { /* ccsCaption - string ccsErrorMessage - string ccsRequired - boolean ccsMinLength - integer ccsMaxLength - integer ccsRegExp - string ccsValidator - validation function ccsInputMask - string */ if (disableValidation) return true; var errorMessage = control.ccsErrorMessage; var customErrorMessage = (typeof(errorMessage) != "undefined"); if (typeof(control.ccsRequired) == "boolean" && control.ccsRequired) if (control.value == "") return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The value in field {0} is required.", control.ccsCaption)); if (typeof(control.ccsMinLength) == "number") if (control.value != "" && control.value.length < parseInt(control.ccsMinLength)) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The number of symbols in field {0} can't be less than {1}.", Array(control.ccsCaption,parseInt(control.ccsMinLength)))); if (typeof(control.ccsMaxLength) == "number") if (control.value != "" && control.value.length > parseInt(control.ccsMaxLength)) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The number of symbols in field {0} can't be greater than {1}.", Array(control.ccsCaption,parseInt(control.ccsMaxLength)))); if (typeof(control.ccsInputMask) == "string") { var mask = control.ccsInputMask; var maskRE = new RegExp(stringToRegExp(mask).replace(/0/g,"\\d").replace(/L/g,"[A-Za-z]"), "i"); if (control.value != "" && (control.value.search(maskRE) == -1)) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The value in field {0} is not valid.", control.ccsCaption)); } if (typeof(control.ccsRegExp) == "string") if (control.value != "" && (control.value.search(new RegExp(control.ccsRegExp, "i")) == -1)) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The value in field {0} is not valid.", control.ccsCaption)); if (typeof(control.ccsDateFormat) == "string") { if (control.value != "" && !checkDate(control.value, control.ccsDateFormat)) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The value in field {0} is not valid. Use the following format: {1}.", Array(control.ccsCaption, control.ccsDateFormat))); } if (typeof(control.ccsValidator) == "function") if (!control.ccsValidator()) return ccsShowError(control, customErrorMessage ? errorMessage : parseParams("The value in field {0} is not valid.", control.ccsCaption)); return true; } function stringToRegExp(string, arg) { var str = String(string); str = str.replace(/\\/g,"\\\\"); str = str.replace(/\//g,"\\/"); str = str.replace(/\./g,"\\."); str = str.replace(/\(/g,"\\("); str = str.replace(/\)/g,"\\)"); str = str.replace(/\[/g,"\\["); str = str.replace(/\]/g,"\\]"); return str; } function checkDate(dateValue, dateFormat) { var DateMasks = new Array( new Array("MMMM", "[a-z]+"), new Array("mmmm", "[a-z]+"), new Array("yyyy", "[0-9]{4}"), new Array("MMM", "[a-z]+"), new Array("mmm", "[a-z]+"), new Array("HH", "([0-1][0-9]|2[0-4])"), new Array("hh", "(0[1-9]|1[0-2])"), new Array("dd", "([0-2][0-9]|3[0-1])"), new Array("MM", "(0[1-9]|1[0-2])"), new Array("mm", "(0[1-9]|1[0-2])"), new Array("yy", "[0-9]{2}"), new Array("nn", "[0-5][0-9]"), new Array("ss", "[0-5][0-9]"), new Array("w", "[1-7]"), new Array("d", "([1-9]|[1-2][0-9]|3[0-1])"), new Array("y", "([1-2][0-9]{0,2}|3([0-5][0-9]|6[0-5]))"), new Array("H", "(00|0?[1-9]|1[0-9]|2[0-4])"), new Array("h", "(0?[1-9]|1[0-2])"), new Array("M", "(0?[1-9]|1[0-2])"), new Array("m", "(0?[1-9]|1[0-2])"), new Array("n", "[0-5]?[0-9]"), new Array("s", "[0-5]?[0-9]"), new Array("q", "[1-4]") ); var regExp = "^"+stringToRegExp(dateFormat)+"$"; for (var i=0; i