function WA_ValidateNM(formElement,errorMsg,minLength,maxLength,allowDecimals,roundDecimals,reformatDecimals,punctuationMarks,focusIt,stopIt,required) { var isValid = true; var theThousand = punctuationMarks.charAt(0); var theDecimal = punctuationMarks.charAt(1); var theCheck = 11/10; var trueDecimal = (String(theCheck).charAt(1)); var value = formElement.value; var decimalIndex = value.length; if (punctuationMarks.indexOf(trueDecimal)<0 && value.indexOf(trueDecimal)>=0) { isValid = false; } if (value.lastIndexOf(theDecimal)>=0) { decimalIndex = value.lastIndexOf(theDecimal); } while (value.indexOf(theThousand)>=0) { decimalIndex = value.length; if (value.lastIndexOf(theDecimal)>=0) { decimalIndex = value.lastIndexOf(theDecimal); } if ((decimalIndex-(value.lastIndexOf(theThousand)+1))%3 != 0) isValid = false; value = value.substring(0,value.lastIndexOf(theThousand)) + value.substring(value.lastIndexOf(theThousand)+1); } if (trueDecimal != theDecimal) { while (value.indexOf(theDecimal)>=0) { value = value.substring(0,value.indexOf(theDecimal)) + trueDecimal + value.substring(value.indexOf(theDecimal)+1); } } if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value=="")) { for (var x=0; x 9) && (value.charAt(x) != " " && value.charAt(x) != "," && value.charAt(x) != ".")) { isValid = false; } } if (value == "") { isValid = false; } var oldVal = String(value); if (oldVal.indexOf(trueDecimal)>=0) { while (oldVal.charAt(oldVal.length-1)=="0" || oldVal.charAt(oldVal.length-1) == trueDecimal) { if (oldVal.charAt(oldVal.length-1) == trueDecimal) { oldVal = oldVal.substring(0,oldVal.length-1); break; } else oldVal = oldVal.substring(0,oldVal.length-1); } if (oldVal.indexOf(trueDecimal)==0) oldVal = "0" + oldVal; } if (String(allowDecimals) !="" ) { if (String(value).indexOf(".") > 0 && ((String(value).indexOf(".") + allowDecimals + 2 <= String(value).length) || allowDecimals == 0)) { isValid = false; } } value = parseFloat(value); if (isNaN(value)) { isValid = false; } else if (String(value).length!=String(oldVal).length && String(oldVal).substring(String(value).length+1).search(/^\.?0*$/) == -1 ) { isValid = false; } else if ((String(minLength) != "" && minLength > value) || (String(maxLength) != "" && maxLength < value)) { isValid = false; } } if (!isValid) { WAAddError(formElement,errorMsg,focusIt,stopIt); } else { if (value != "") { if (roundDecimals != "") { value = Math.round(value*roundDecimals)/roundDecimals; } if (reformatDecimals != "") { value = String(value); if (value.indexOf(trueDecimal)<0) value += trueDecimal; if (value.indexOf(trueDecimal) < value.length - reformatDecimals) { value = value.substring(0,value.indexOf(trueDecimal) + reformatDecimals + 1); } else { while (value.indexOf(trueDecimal) > value.length - reformatDecimals - 1) { value += "0"; } } } } if (trueDecimal != theDecimal) { value = String(value); while (value.indexOf(trueDecimal)>=0) { value = value.substring(0,value.indexOf(trueDecimal)) + theDecimal + value.substring(value.indexOf(trueDecimal)+1); } } if (roundDecimals != "" || reformatDecimals != "") formElement.value = value; } } function WAtrimIt(theString,leaveLeft,leaveRight) { if (!leaveLeft) { while (theString.charAt(0) == " ") theString = theString.substring(1); } if (!leaveRight) { while (theString.charAt(theString.length-1) == " ") theString = theString.substring(0,theString.length-1); } return theString; } function WAAddError(formElement,errorMsg,focusIt,stopIt) { if (document.WAFV_Error) { document.WAFV_Error += "\n" + errorMsg; } else { document.WAFV_Error = errorMsg; } if (!document.WAFV_InvalidArray) { document.WAFV_InvalidArray = new Array(); } document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement; if (focusIt && !document.WAFV_Focus) { document.WAFV_Focus = focusIt; } if (stopIt == 1) { document.WAFV_Stop = true; } else if (stopIt == 2) { formElement.WAFV_Continue = true; } else if (stopIt == 3) { formElement.WAFV_Stop = true; formElement.WAFV_Continue = false; } } function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,trimWhite,inputType) { var isValid = true; if (!document.WAFV_Stop && !formElement.WAFV_Stop) { if (inputType == "select") { if (formElement.selectedIndex == -1) { isValid = false; } else if (!formElement.options[formElement.selectedIndex].value || formElement.options[formElement.selectedIndex].value == "") { isValid = false; } } else if (inputType == "checkbox") { if (formElement.length) { isValid = false; focusIt = false; for (var x=0; x 127 && userName.charCodeAt(x) < 192) || userName.charCodeAt(x) > 255) { isValid = false; } } for (x=0; x < domainName.length; x++) { if ((domainName.charCodeAt(x) > 127 && domainName.charCodeAt(x) < 192) || domainName.charCodeAt(x) > 255) { isValid = false; } } if (userName.match(userPat) == null) { isValid = false; } if (IPArray != null) { for (var x=1; x<=4; x++) { if (IPArray[x] > 255) { isValid = false; } } } for (x=0; x < domArr.length; x++) { if (domArr[x].search(acceptedPat) == -1 || domArr[x].length == 0 || (domArr[x].length < 2 && x >= domArr.length-2)) { isValid = false; } } if (domArr[domArr.length-1].length !=2 && domArr[domArr.length-1].search(knownDomsPat) == -1) { isValid = false; } if (domArr.length < 2) { isValid = false; } } } if (!isValid) { WAAddError(formElement,errorMsg,focusIt,stopIt); } } function WAValidateZC(formElement,errorMsg,us5,us9,can6,uk,reformat,focusIt,stopIt,required) { var value = formElement.value; var isValid = true; var allowed = "() -.\n\r"; var hasLetters = false; if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value=="")) { var newVal = ""; var charVal = ""; for (var x=0; x= "0") && (z <= "9")) { newVal += z; charVal += "N"; } else { if ((uk || can6) && ((z >= "a") && (z <= "z")) || ((z >= "A") && (z <= "Z"))) { charVal += "A"; hasLetters = true; } else if (allowed.indexOf(z) < 0 || x==0 || x == value.length-1) { isValid = false; } } } if ((uk || can6) && hasLetters) { var acceptPattern = ""; if (uk) { acceptPattern += ",ANNAA,ANNNAA,AANNAA,AANNNAA,ANANAA,AANANAA,"; } if (can6) { acceptPattern += ",ANANAN,"; } if (String(acceptPattern).indexOf(","+charVal+",") < 0) isValid = false; } if (!((uk && (charVal.length >= 5 && charVal.length <= 8)) || (us5 && newVal.length == 5) || (us9 && newVal.length == 9) || (can6 && charVal.length == 6))) { isValid = false; } if (isValid && !hasLetters && (us5 || us9)) { if (us5) { isValid = (value.search(/^\d{5}$/) == 0); } if (us9 && ((us5 && !isValid) || !us5)) { isValid = ((value.search(/^\d{5}[-\. ]\d{4}$/) == 0) || (value.search(/^\d{9}$/) == 0)); } } } if (!isValid) { WAAddError(formElement,errorMsg,focusIt,stopIt); } else { if (reformat != "") { if (reformat != "t") { for (var x=0; x=0) { reformat = reformat.substring(0,reformat.indexOf("x")); while (reformat.charAt(reformat.length-1) == " " || reformat.charAt(reformat.length-1) == "-") reformat = reformat.substring(0,reformat.length-1); z = reformat.charAt(reformat.length-1); } if (newVal.length==6) reformat = reformat.replace(/-/,""); } else { newVal = formElement.value; while (newVal.charAt(0) == " ") newVal = newVal.substring(1); while (newVal.charAt(newVal.length-1) == " ") newVal = newVal.substring(0,newVal.length-1); reformat = newVal; } formElement.value = reformat; } } } function WAValidatePN(formElement,errorMsg,areaCode,international,reformat,focusIt,stopIt,required) { var value = formElement.value; var isValid = true; var allowed = "*() -./_\n\r+"; var newVal = ""; if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value=="")) { for (var x=0; x= "0") && (z <= "9")) { newVal += z; } else { if (allowed.indexOf(z) < 0) { isValid = false; } } } if (international) { if (newVal.length < 5) { isValid = false; } } else if (newVal.length == 11) { if (newVal.charAt(0) != "1") { isValid = false; } } else if ((newVal.length != 10 && newVal.length != 7) || (newVal.length==7 && areaCode)) { isValid = false; } } if (!isValid) { WAAddError(formElement,errorMsg,focusIt,stopIt); } else { formElement.WAValid = true; if (reformat != "" && newVal != "") { for (var x=0; x=0) { reformat = reformat.substring(reformat.lastIndexOf("x")+1); z = reformat.charAt(0); while (((z < "0") || (z > "9")) && z != "(") { reformat = reformat.substring(1); z = reformat.charAt(0); } } formElement.value = reformat; } } } function WA_isCreditCard(st) { if (st == 0) return (false); if (st.length > 19) return (false); sum = 0; mul = 1; l = st.length; for (i = 0; i < l; i++) { digit = st.substring(l-i-1,l-i); tproduct = parseInt(digit ,10)*mul; if (tproduct >= 10) sum += (tproduct % 10) + 1; else sum += tproduct; if (mul == 1) mul++; else mul--; } if ((sum % 10) == 0) return (true); else return (false); } function WAValidateCC(formElement,value,errorMsg,format,allow,focusIt,stopIt,required) { var isValid = true; var accepted = "\r\n\t.- "; if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value=="")) { var stripVal = ""; for (var x=0; x=48 && value.charCodeAt(x)<=57) stripVal += value.charAt(x); else if (accepted.indexOf(value.charAt(x))<0) { isValid = false; } } if (isValid) { if (allow!="") { isValid = false; allow = allow.split(":"); for (var y=0; y0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i