//Verify an input string based on a primitive number type function mVerifyNumber(str,useMin,minVal,useMax,maxVal,precision) { //Check to see that we indeed have a number (integer or decimal) var re; if (precision == 0) re = new RegExp("^[0-9]+$"); else re = new RegExp("^(([0-9]+)|([0-9]*\\.[0-9]+))$"); if (!re.test(str)) return false; //Check precision, and parse the number accordingly if (precision == 0) val = parseInt(str); else val = parseFloat(str); //Make sure the number is in the valid range if (useMin && val < minVal) return false; if (useMax && val > maxVal) return false; return true; } function mParseNumber(str,precision) { //Check to see that we indeed have a number (integer or decimal) var re = new RegExp("([0-9]+)|([0-9]*\\.[0-9]+)"); if (!re.test(str)) return 0; //Check precision, and parse the number accordingly if (precision == 0) return parseInt(str); else return parseFloat(str); } function mVerifyString(str,minLen,maxLen,ic,verification) { //Check string length is in the valid range if (str.length > maxLen && maxLen != -1) return false; if (str.length < minLen && minLen != -1) return false; //Check for invalid characters in the string for (i=0;i 12) return false; if ((month % 2 == 1 && month < 8) || (month % 2 == 0 && month > 7) ) daymax = 31; else daymax = 30; if (month == 2) daymax = ( year % 4 == 0 ? 29 : 28 ); if (day < 1 || day > daymax) return false; date = new Date(year,month-1,day); //Test to see that the date is in the valid range if (useMin) { if (!minUseCurrent) { minDate = minVal; } else minDate = new Date(); minDate.setMinutes(0); minDate.setHours(0); minDate.setSeconds(0); if (date < minDate) return false; } if (useMax) { if (maxUseCurrent) { maxDate = maxVal; } else maxDate = new Date(); maxDate.setMinutes(59); maxDate.setHours(23); maxDate.setSeconds(59); if (date > maxDate) return false; } return true; } function mParseDate(str) { var date,month,day,year,daymax; var s = new String(str); //Test to see that the string is of the format ##/##/## var re = new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"); if (!re.test(str)) return new Date(); //Interpret the string as MM/DD/YY month = s.substring(0,2); day = s.substring(3,5); year = s.substring(6,10); //Make sure this is a valid date if (month < 1 || month > 12) return new Date(); if ((month % 2 == 1 && month < 8) || (month % 2 == 0 && month > 7) ) daymax = 31; else daymax = 30; if (month == 2) daymax = ( year % 4 == 0 ? 29 : 28 ); if (day < 1 || day > daymax) return new Date(); return new Date(year,month-1,day); } function replaceQuotes(str) { var s = new String(str); var out = ""; if (s.indexOf("'") == -1) return str; while ( (i = s.indexOf("'")) != -1) { out = out + s.substring(0,i+1) + "'"; s = s.substring(i+1,s.length); } out = out + s; return out; } function replaceDQuotes(str) { var s = new String(str); var out = ""; if (s.indexOf("\"") == -1) return str; while ( (i = s.indexOf("\"")) != -1) { out = out + s.substring(0, i) + "\\\""; s = s.substring(i+1,s.length); } out = out + s; return out; } function replaceBackslash(str) { var s = new String(str); var out = ""; if (s.indexOf("\\") == -1) return str; while ( (i = s.indexOf("\\")) != -1) { out = out + s.substring(0,i) + "\\\\"; s = s.substring(i+1,s.length); } out = out + s; return out; } function padZero(str, desiredLen, left) { While (str.length < desiredLen) if (left) str = "0" + str; else str = str + "0"; return str; } var oldItem = null; function j2(i,f) { i.className = 'regtextCaption2' document.location = "#" + i.id; if (!f.disabled) f.focus(); if (oldItem != null && oldItem != i) oldItem.className = "regtextCaption" oldItem = i; return false; } function jTrim(x) { while (x.charAt(0) == '\t' || x.charAt(0) == '\n' || x.charAt(0) == ' ') x = x.substring(1,x.length); while (x.charAt(x.length-1) == '\t' || x.charAt(x.length-1) == '\n' || x.charAt(x.length-1) == ' ') x = x.substring(1,x.length); return x; } function verifyDimension(f) { if (!f.disabled) f.value = jTrim(f.value); if (!mVerifyNumber(f.value, true, 0, false, 0, 2)) { alert("Invalid Dimension"); if (!f.disabled) f.focus(); return false; } return true; } function parseDimension(str) { mParseNumber(str, 2); } function verifyNumRange(sNum, eNum) { _rVal = true; if (_rVal) { /////////////////////////////////////////////////////////////////////////////////// //Customized script entered in type definition /////////////////////////////////////////////////////////////////////////////////// if (sNum.value > eNum.value ) {_rVal = false;} /////////////////////////////////////////////////////////////////////////////////// //End of customized script /////////////////////////////////////////////////////////////////////////////////// } if (_rVal) return true; alert("The minimum must be less than the maximum."); return false; } function createNumRange( sNumeNum) { //Create the object var tObj = new Object(); var argv = createNumRange.arguments; tObj.sNum = sNum; tObj.eNum = eNum; return tObj; } function verifyPrice(f) { if (!f.disabled) f.value = jTrim(f.value); if (!mVerifyNumber(f.value, false, 0, false, 0, 2)) { alert("Invalid Price"); if (!f.disabled) f.focus(); return false; } return true; } function parsePrice(str) { mParseNumber(str, 2); }