// Global Variables var i = 1; var n = 1; var digits = "0123456789"; var defaultEmptyOK = false // whitespace characters var whitespace = " \t\n\r"; NOT_ENOUGH_DIGITS = -3; TOO_MANY_DIGITS = -2; UNKNOWN_VENDOR = -1; N = 14; // ---------- Validation messages ------------- // Validation messages var requiredPrefix = "" var requiredSuffix = " is a required field. If it is blank, you will not be able to proceed." var requiredEmailPrefix = "Please ensure the email address you typed in the " var requiredEmailSuffix = "field is in the correct format, such as (you@youremail.com)." var requiredEmailAreaPrefix = "Please ensure the address you typed in the " var requiredEmailAreaSuffix = " field is in the correct format, such as (you@meetmark.com)." var requiredCheckboxPrefix = "You will not be able to continue without checking the " var requiredCheckboxSuffix = " checkbox." var requiredMaxSizePrefix = "The value you entered into the " var requiredMaxSizeMiddle= " field is too long. Please shorten your input to a maximum of " var requiredMaxSizeSuffix = " characters." var requiredEmailMaxSizePrefix = "The email address you entered in the " var requiredEmailMaxSizeMiddle= " field is too long. Maximum characters allowed is " var requiredEmailMaxSizeSuffix = "." var requiredRadioButtonPrefix = "Please select an option for the " var requiredRadioButtonSuffix = " field." var minSizePrefix="Your entry for the " var minSizeMiddle=" field must be at least " var minSizeSuffix=" characters." // Numeric fields var invalidNumericStringPrefix = "Please enter only numbers (0123456789) in the " var invalidNumericStringSuffix = " field." // Alphabetic fields var invalidAlphaStringPrefix = "" var invalidAlphaStringSuffix = " must contain only letters or the characters apostrophe(') or dash (-)." // Date messages var iDatePrefix = "Please use the format MM/DD/YYYY in the " var iDateSuffix = " field." var dateFormatPrefix = "\nInvalid date format. Must be in format " var dateFormat = "MM/DD/YYYY" var InvalidDay = "\nInvalid day.\nPlease enter a valid day." var InvalidMonth = "\nInvalid month.\nPlease enter a valid month." var InvalidYear = "\nInvalid year.\nPlease enter the year as a 4-digit number." var invalidPostcode = "The zip code you entered was invalid." // non-digit characters which are allowed in phone numbers var phoneNumberDelimiters = "()-" // characters which are allowed in international phone numbers // (a leading + is OK) var validWorldPhoneChars = digits + phoneNumberDelimiters + "+"; // non-digit characters which are allowed in ZIP Codes var ZIPCodeDelimiters = "-" // Extra messages for local SK functions var requiredCardMessage = "Please select a Card Type." var older13 = "You cannot use the site under the age of 13."; var privacy_policy = "You must read and agree to our privacy policy in order to continue."; var invalidConfirmationPrefix = "Your confirmation does not match the value you entered in the "; var invalidConfirmationSuffix =" field. Please re-enter your information."; var requiredCardData = "If you enter data into any of the credit card information fields, you must fill in all of them in order to get through the credit card verification process."; var cardCheckFailed = " cannot be authorized. Please check your credit card information and try again. If you believe your information is correct, please contact your card's Customer Service."; var requiredPasswordAll = "If you enter data into any of the 4 password fields, you must fill in all of them."; var invalidPhoneNumberPrefix = "Please use the format 999-999-9999 for the "; var invalidPhoneNumberSuffix = " field."; var notLoggedIn = "You are not logged in. Please log in and try this function again."; var invalidDayPrefix = "The day you entered in the " ; var invalidDaySuffix = " field is invalid. It must be a number between 1 and 31." ; var invalidMonthPrefix = "The month you entered in the " ; var invalidMonthSuffix = " field is invalid. It must be a number between 1 and 12." ; var invalidYearPrefix = "The year you entered in the " ; var invalidYearSuffix = " field is invalid." ; // Read propreties of credit card from application property file var invalidSSNumberPrefix = "The correct format for the " var invalidSSNumberSuffix = " field is 999-99-9999." var requiredCollege = "Please select a value from the college drop-down list." var requiredContactNumber = "You must fill in at least one phone number." low = [ 340000000000000,370000000000000,4000000000000,4000000000000000,5100000000000000,6011000000000000 ] high = [ 349999999999999,379999999999999,4999999999999,4999999999999999,5599999999999999,6011999999999999 ] len = [ 15,15,13,16,16,16 ] vendor = [ "AX","AX","V ","V ","M ","D " ] mod10 = [ true,true,true,true,true,true ] /* FUNCTIONS TO NOTIFY USER OF INPUT REQUIREMENTS OR MISTAKES. */ /* function helpON(hover, help){ document[helpON.arguments[0]].src = helpON.arguments[1]; } function helpOFF(hover, help){ document[helpON.arguments[0]].src = helpON.arguments[1]; } */ // Notify user that required field theField is empty. // String cur describes expected contents of theField.value. // Put focus in theField and return false. function warnEmpty (theField, cur) { theField.focus(); alert(requiredPrefix + cur + requiredSuffix); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Empty_" + cur; } return false; } // Notify user that contents of field theField are invalid. // String c describes expected contents of theField.value. // Select theField, put focus in it, and return false. function warnInvalid (theField, cur) { theField.focus(); theField.select(); alert(requiredEmailPrefix + cur + requiredEmailSuffix); return false; } function warnInvalidEmailArea (theField, cur) { theField.focus(); theField.select(); alert(requiredEmailAreaPrefix + cur + requiredEmailAreaSuffix); return false; } // Email Area function warnInvalidMaxSize (theField, cur, maxsize) { theField.focus(); theField.select(); alert(requiredEmailMaxSizePrefix + cur + requiredEmailMaxSizeMiddle + maxsize + requiredEmailMaxSizeSuffix); return false; } // Numbers function warnInvalidNumericString (theField, cur) { theField.focus(); theField.select(); alert(invalidNumericStringPrefix + cur + invalidNumericStringSuffix); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Error_" + cur; } return false; } // Alphabetic function warnInvalidAlphaString (theField, cur) { theField.focus(); theField.select(); alert(invalidAlphaStringPrefix + cur + invalidAlphaStringSuffix); return false; } // DateFormat function warnInvalidDateFormat (theField, cur) { theField.focus(); theField.select(); //alert(cur + ": " + dateFormatPrefix + dateFormat); alert(iDatePrefix+cur+iDateSuffix); return false; } // Day function warnInvalidDay (theField, cur) { theField.focus(); theField.select(); //alert(cur + ": " + InvalidDay); alert(invalidDayPrefix + cur + invalidDaySuffix); return false; } // Month function warnInvalidMonth (theField, cur) { theField.focus(); theField.select(); //alert(cur + ": " + InvalidMonth); alert(invalidMonthPrefix + cur + invalidMonthSuffix ); return false; } // Year function warnInvalidYear (theField, cur) { theField.focus(); theField.select(); //alert(cur + ": " + InvalidYear); alert(invalidYearPrefix + cur + invalidYearSuffix); return false; } function warnConfirmation (theField, theLabel) { theField.focus(); theField.select(); alert(invalidConfirmationPrefix + theLabel + invalidConfirmationSuffix); return false; } function warnAllCard () { alert(requiredCardData); return false; } function warnAllPassword() { alert(requiredPasswordAll); return false; } function warnInvalidPhone (field, label) { field.focus(); field.select(); alert (invalidPhoneNumberPrefix + label + invalidPhoneNumberSuffix); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Error_" + label; } return false; } // Check whether string cur is empty. function isEmpty(cur) { return ((cur == null) || (cur.length == 0)); } function ConverttoUpper(cur) { cur.value = cur.value.toUpperCase(); } // ---------------- Clear String Whitespace --------------- // Removes all characters which appear in string bag from string s. function stripCharsInBag (s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } // Removes all trailing characters which appear in string bag from string s. function stripTrailingWhitespace (s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += " " + c; } return returnString.substring(1); } // Removes all trailing characters which appear in string bag from string s. function stripLeadingAndTrailingWhitespace (s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. var start = -1; var end = -1; for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) end = i; } for (i = s.length; i >= 0; i--) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) start = i; } if (start == -1 && end == -1) return returnString; return s.slice(start, end +1); } // Removes all whitespace characters from s. // Global variable whitespace (see above) // defines which characters are considered whitespace. function stripWhitespaceEmail (s) { return stripLeadingAndTrailingWhitespace (s, whitespace) } function isWhitespace (cur) { var i; // Is cur empty? if (isEmpty(cur)) return true; // Search through string's characters one by one // until we find a non-whitespace character. // When we do, return false; if we don't, return true. for (i = 0; i < cur.length; i++) { // Check that current character isn't whitespace. var c = cur.charAt(i); if (whitespace.indexOf(c) == -1) return false; } // All characters are whitespace. return true; } function isWhitespaceEmail (cur) { var i; // Is cur empty? if (isEmpty(cur)) return true; // Search through string's characters one by one // until we find a whitespace character. // When we do, return true for (i = 0; i < cur.length; i++) { // Check that current character isn't whitespace. var c = cur.charAt(i); if (whitespace.indexOf(c) == 0) { return true; } } // No characters are whitespace. return false; } var testresults function isEmail(s){ var str = stripWhitespaceEmail(s); var filter=/^(\w+(?:(\.|\-)\w+)*)@((?:\w+(\.|\-))*\w[\w-]{0,66})\.([a-z]{2,3}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ testresults=false } return (testresults) } function checkString (theField, cur, emptyOK) { // Next line may be needed on to avoid "undefined is not a number" error // in equality comparison below. if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (isWhitespace(theField.value)) return warnEmpty (theField, cur); else return true; } function checkEmail (theField, cur, emptyOK) { if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isEmail(theField.value)) return warnInvalid (theField, cur); else return true; } function checkAreaEmail (theField, cur, emptyOK, maxlength) { if (checkAreaEmail.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else { var number = 1; var temp = theField.value; var second = temp.indexOf(','); while (second != -1) { var email = temp.substring(0, second); email = stripWhitespaceEmail(email); if (email != "") { if (email.length > maxlength) return warnInvalidMaxSize (theField, email, maxlength); if (!isEmail(email)) return warnInvalidEmailArea (theField, email); } temp = temp.substring(second+1, temp.length); second = temp.indexOf(','); number++; } temp = stripWhitespaceEmail(temp); if (temp != "") { if (temp.length > maxlength) return warnInvalidMaxSize (theField, temp, maxlength); if (!isEmail(temp)) return warnInvalidEmailArea (theField, temp); } return true; } } // Check that checkbox is checked function isChecked (theField, cur) { if (theField.checked) { return true; } alert(requiredCheckboxPrefix + cur + requiredCheckboxSuffix) if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Empty_"+cur; } return false; } function isCheckedS (theField) { if (theField.checked) { return true; } if (theField.name == "older13"){ alert(older13) return false; } if (theField.name == "privacy_policy"){ alert(privacy_policy) return false; } } // Check that radio button is checked function isRadioChecked (theField, cur) { for (var i = 0; i < theField.length; i++) { if (theField[i].checked) { return true; } } alert(requiredRadioButtonPrefix + cur + requiredRadioButtonSuffix) return false; } function withinMaxLength (theField, cur, maxsize) { // var maxsize = 2000; val = theField.value if (val.length > maxsize) { alert(requiredMaxSizePrefix + cur + requiredMaxSizeMiddle + maxsize + requiredMaxSizeSuffix); return false; } // Value is not > max Size return true; } // Checks to ensure the value entered by the user is greater than // the min allowed length. //Note: The check will be skipped if the user hasn't entered a value. // If the field should have a value, then set the mandatory flag to Y in // page property file and the warnEmpty Funtion will then be called. function checkMinLength(theField, cur, minlength){ var val = theField.value; if ( (val.length>0) && (val.length< minlength) ) { return warnInvalidMinLength(theField, cur, minlength); } // Value is > min length return true; } function warnInvalidMinLength(theField, cur, minlength){ theField.focus() theField.select() alert(minSizePrefix + cur + minSizeMiddle + minlength + minSizeSuffix); return false; } function submit_onClick(form) { return validateRequired(form); } //----------------- Number -------------------- // Beginning of Input, followed by one or more digits, followed by End of Input. var reIntegers = /^\d+$/ // isIntegerString (STRING s [, BOOLEAN emptyOK]) // Returns true if all characters in string s are numbers. // Accepts non-signed integers only. function isIntegerString (s) { var i; if (isEmpty(s)) if (isIntegerString.arguments.length == 1) return defaultEmptyOK; else return (isIntegerString.arguments[1] == true); return reIntegers.test(s) } function checkNumberString(theField, cur, emptyOK) { if (checkNumberString.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (!isIntegerString(theField.value)) return warnInvalidNumericString (theField, cur); else return true; } // ---------------- Alphabetic -------------- // Beginning of Input, followed by one or more lower or uppercase English letters, // followed by End of Input. var reAlphabetic = /^[a-zA-Z\'\.\-\s]+$/ //var reAlphabetic = /^[^0-9?]+$/ // isAlphabetic (STRING s [, BOOLEAN emptyOK]) // Returns true if string s is English letters // (A .. Z, a..z) only. // NOTE: Need extra validation to support extra European characters. function isAlphabetic (s) { var i; if (isEmpty(s)) if (isAlphabetic.arguments.length == 1) return defaultEmptyOK; else return (isAlphabetic.arguments[1] == true); else { return reAlphabetic.test(s) } } function checkAlphaString(theField, cur, emptyOK) { if (checkAlphaString.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (!isAlphabetic(theField.value)) return warnInvalidAlphaString (theField, cur); else return true; } // ---------------------- Date ----------------------- function checkDigit( value ) { var i = value.length; var ch; var j=0; for ( j=0;j='0' && ch <= '9') ) { return false; } } return true; } function checkDigitRange( value, min, max ) { //alert("value: "+ value + ", min: " + min + ", max: " + max) if ( checkDigit( value ) ) { if ( value >= min && value <=max ) { //alert( 'Within Range ' + min + " -- " + max ); return true; } else { //alert( 'NOT Within Range ' + min + " -- " + max ); return false; } } else { //alert( 'not digit ' + "[" + value + "] " + min + " -- " + max ); return false; } } function getMM( value ) { var i = value.indexOf( '/' ); if (dateFormat == "MM/DD/YYYY") { return value.substring(0,i); } else { var j= value.lastIndexOf( '/' ); return value.substring( i+1, j ); } } function getDD( value ) { var i= value.indexOf( '/' ); if (dateFormat == "MM/DD/YYYY") { var j= value.lastIndexOf( '/' ); return value.substring( i+1, j ); } else { return value.substring(0,i); } } function getYYYY( value ) { var i = value.length; var j = value.lastIndexOf( '/' ); return value.substring( j+1, i+1 ); } function getFullYear(d) { var y = d.getYear(); if ( y < 1000 ) y += 1900; return y; } function checkDate( theField, cur, emptyOK ) { if (checkDate.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; var i=theField.value.indexOf( '/' ); var j=theField.value.lastIndexOf( '/' ); var days_in_month=0; // Must be in mm/dd/yyyy or dd/mm/yyyy format if ( theField.value.length != 10 ) { return warnInvalidDateFormat (theField, cur); } if ( i < j ) { // we have more than 2 occurences of / var mm=getMM( theField.value ); if ( !checkDigitRange( mm,1,12) ) { return warnInvalidMonth (theField, cur); } var dd=getDD( theField.value ); var yy=getYYYY( theField.value ); //alert("mm =" + mm + " dd= " + dd + " yy= " + yy); if (mm == 01) days_in_month = 31; else if (mm == 02) if ((yy % 4) == 0) { days_in_month = 29; } else days_in_month = 28; else if (mm == 03) days_in_month = 31; else if (mm == 04) days_in_month = 30; else if (mm == 05) days_in_month = 31; else if (mm == 06) days_in_month = 30; else if (mm == 07) days_in_month = 31; else if (mm == "08") days_in_month = 31; else if (mm == "09") days_in_month = 30; else if (mm == 10) days_in_month = 31; else if (mm == 11) days_in_month = 30; else if (mm == 12) days_in_month = 31; if ( !checkDigitRange( dd,1,days_in_month) ) { return warnInvalidDay (theField, cur); } var dt = new Date(); var curYear = getFullYear(dt); var curMonth = dt.getMonth(); curMonth = curMonth + 1; var curDay = dt.getDate(); //alert("curYear: " + curYear); //alert("yy: " + yy); /* if ((curYear - yy) == 18) { // alert("curYr - yy == 18"); if (curMonth < mm) { return warnInvalidMonth (theField, cur); } if (curDay < dd) { return warnInvalidDay (theField, cur); } }*/ if ( !(checkDigitRange( yy,1900,curYear )) ) { // alert ("check digit failed"); return warnInvalidYear (theField, cur); } return true; } else { // alert ("more than 2 occurrences of /"); alert( dateFormatPrefix + dateFormat ); return false; } } //-----------------------Listbox---------------------------- function warnEmptyList (theField, cur) { theField.focus() //cur.select() alert(requiredPrefix + cur + requiredSuffix) if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Empty_" + cur; } return false } // Get selected value from listbox function getListboxValue(list) { return list.options[list.selectedIndex].value } // Verify Listbox function checkListbox(theField, cur, emptyOK) { var selectedValue = getListboxValue(theField) // Next line may be needed on to avoid "undefined is not a number" error // in equality comparison below. if (checkListbox.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(selectedValue))) return true; if ((selectedValue == "*") && (emptyOK == true)) return true; if (selectedValue == "*") { selectedValue = ""; } if (isWhitespace(selectedValue)) { if (theField.name == "collegename") { return warnEmptyCollege(theField, cur); } else { return warnEmptyList(theField, cur); } } else return true; } //Checks if a greeting card type has been selected function isCardChecked(theField){ for (var i = 0; i < theField.length; i++) { if (theField[i].checked) { return true; } } alert(requiredCardMessage) return false; } function AVsitestatForm(frmNm) { ns_l="https://uk.sitestat.com/avoncosmetics/uspr/s?repsuite."+frmNm; ns_l+="&ns_type=submit&ns_t="+(new Date()).getTime(); ns_pixelUrl=ns_l; if(document.images) { ns_l2=new Image(); ns_l2.src=ns_l; } else document.write(""); } //-----------------------Postcode---------------------------- // Format: 99999-9999 or 99999 function checkPostcode (theField) { cur = theField.value; if (isEmpty(cur)) return true; if (cur.length == 5 && isIntegerString(cur)) return true; if (cur.length == 10) { if (cur.indexOf('-') != -1) first = cur.substring(0,5); last = cur.substring(6, cur.length); if (cur.indexOf('-') == 5 && isIntegerString(first) && isIntegerString(last)) return true; } theField.focus(); alert(invalidPostcode); return false; } function checkZipcode(field,emptyOK) { if (checkZipcode.arguments.length == 1) emptyOK = defaultEmptyOK; val = field.value; if ((emptyOK == true) && (isEmpty(val))) return true; if (val.length != 5) { field.focus(); field.select(); alert (invalidPostcode); return false; } else { return true; } } function isOther(list, other, label_other) { ind = list.selectedIndex; val = list.options[ind].value; if (val == "OTHRS") { other.disabled = false; //return checkString (other, label_other); } else { return true; } } function confirmation(theField1, theField2, theLabel, emptyOK) { if (confirmation.arguments.length == 3) emptyOK = defaultEmptyOK; if (theField1.value != theField2.value) return warnConfirmation (theField1, theLabel); else return true; } function notOptional(field1, field2, cur1, cur2) { ind = field1.selectedIndex; val1 = field1.options[ind].value; val2 = field2.value; if ((val1 == "*") && (isEmpty(val2))) { return true; } else { return ( checkString(field2, cur2) && checkListbox(field1, cur1)); } } function copyBillShip(same, addr1, addr2, city, state, zip, saddr1, saddr2, scity, sstate, szip){ if (same.checked) { saddr1.value = addr1.value; saddr2.value = addr2.value; scity.value = city.value; sstate.value = state.value; szip.value = zip.value; } } function checkCard (field1, field2) { var val1 = field1.value; var val2 = field2.value; if ((isEmpty(val1)&&(val2 != "*"))||((val2 == "*")&&(!isEmpty(val1)))) { warnAllCard(); } else { return true; } } function checkAllCard (field1, field2, field3, field4, field5, field6) { var val1 = field1.value; ind2 = field2.selectedIndex; val2 = field2.options[ind2].value; var val3 = field3.value; var val4 = field4.value; ind5 = field5.selectedIndex; val5 = field5.options[ind5].value; ind6 = field6.selectedIndex; val6 = field6.options[ind6].value; if ((!isEmpty(val1) && (val2 != "*") && !isEmpty(val3) && isEmpty(val4) && (val5 != "*") && (val6 != "*")) || ( isEmpty(val1) && (val2 == "*") && isEmpty(val3) && isEmpty(val4) && (val5 == "*") && (val6 == "*")) || (!isEmpty(val1) && (val2 != "*") && isEmpty(val3) && !isEmpty(val4) && (val5 != "*") && (val6 != "*")) || (!isEmpty(val1) && (val2 != "*") && !isEmpty(val3) && !isEmpty(val4) && (val5 != "*") && (val6 != "*")) ){ return true; } else { warnAllCard(); } } function checkAllPasswordField (field1, field2, field3, field4) { var val1 = field1.value; var val2 = field2.value; var val3 = field3.value; var val4 = field4.value; if ((isEmpty(val1) && isEmpty(val2) && isEmpty(val3) && isEmpty(val4)) || (!isEmpty(val1) && !isEmpty(val2) && !isEmpty (val3) && !isEmpty(val4))) { return true; } else { warnAllPassword(); } } function autoTabHandler(event) { event = event || window.event; var ctl = event.target || event.srcElement; if (ctl.value.length == ctl.maxLength) { var keyCode = event.keyCode || event.which; if (keyCode == 32 || keyCode >= 48) { // heuristics for printable characters; see http://lists.w3.org/Archives/Public/www-archive/2006Nov/att-0047/keyCode-ie.htm var nextctl = _nextCtl(ctl); if (nextctl) nextctl.focus(); } } return true; } function _nextCtl(ctl) { var ctls = ctl.form.elements; for (var i=0; i 9999999999999999) return TOO_MANY_DIGITS; for (i = 0; i < N; i++) { if (low[i] <= creditCardNumber && creditCardNumber <= high[i]) return i; } return UNKNOWN_VENDOR; } // used in computing checksums, doubles and adds resulting digits. // 0->0 1->2 2->4 3->6 4->8 5->1 6->3 7->5 8->7 9->9 function z(digit) { if (digit == 0) return 0; return (digit*2-1) % 9 + 1; } function checkCreditCard(theList, theField, cur, emptyOK) { if (checkCreditCard.arguments.length == 3) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; var creditCardNumber = parseDirtyNumber(theField.value); var I = 0; switch (I = findMatchingRange(creditCardNumber)) { case NOT_ENOUGH_DIGITS: alert(cur + cardCheckFailed); return false; case TOO_MANY_DIGITS: alert(cur + cardCheckFailed); return false; case UNKNOWN_VENDOR: alert(cur + cardCheckFailed); return false; } if (mod10[I]) { number = creditCardNumber; checksum = 0; for (place = 0; place < 16; place++) { digit = number % 10; number = Math.floor(number/10); if ((place & 1) == 0) // even position, just add digit checksum += digit; else // odd position, must double and add checksum += z(digit); if (number == 0) break; } // good checksum should be 0 mod 10 if ((checksum % 10) != 0) { alert(cur + cardCheckFailed); return false; } } creditCardType = new String(theList.value); if (creditCardType != vendor[I]) { alert(cur + cardCheckFailed); return false; } return true; } //You entered an invalid telephone number. Valid format is 999-999-9999. function checkPhone(field1, field2, field3, label){ var length1 = field1.value.length; var length2 = field2.value.length; var length3 = field3.value.length; if ( length1 ==0 && length2 == 0 && length3 == 0) return true; if (field1.value == 0 && field2.value == 0 && field3.value == 0) { warnInvalidPhone(field1, label); return false; } if ( (length1 != 3) || (length2 != 3) || (length3 != 4) ){ if (length1 != 3) { field = field1; } else { if (length2 != 3) field = field2; else field = field3; } warnInvalidPhone(field,label); } else return true; } function confirmLog (field) { //function confirmLog (field,form,action) { //form = document.SelectedRepForm //action = "../application/formsGenerator?page=selectedrep"; if(field.checked) { val = field.value; if (val == "loginfalse") { if (confirm(notLoggedIn)) { field.value = "login"; window.location="/PRSuite/buy/shop/login?prev=/buy/replocator.jsp"; //document.SelectedRepForm.action="../application/formsGenerator?page=selectedrep"; //return true; return false; } else { field.checked = false; return true; } } else { return true; } } else { return true; } } function clearOtherColleges(list, other) { ind = list.selectedIndex; val = list.options[ind].value; if (val != "OTHRS") { other.value=""; other.disabled = true; } else { other.disabled = false; } return true; } function checkMobilePhoneEntry(checkbox, phone1, phone2, phone3, label) { if (checkbox.checked) { if (phone1.value =='' || phone1.value==null || phone2.value == '' || phone2.value==null || phone3.value=='' || phone3.value == null) { return checkString(phone1, label); } } else { if (phone1.value !='' && phone1.value != null && phone2.value != '' && phone2.value != null && phone3.value != '' && phone3.value != null) { return isChecked(checkbox, 'acceptance for mobile communication '); } } return true; } //You entered an invalid Social Security number. Valid format is 999-99-9999. function checkSSNumber(field1, field2, field3, label) { var length1 = field1.value.length; var length2 = field2.value.length; var length3 = field3.value.length; if ( length1 ==0 && length2 == 0 && length3 == 0) return true; if (field1.value == 0 && field2.value == 0 && field3.value == 0) { warnInvalidSSNumber(field1,label); return false; } if ( (length1 != 3) || (length2 != 2) || (length3 != 4) ){ if (length1 != 3) { field = field1; } else { if (length2 != 2) field = field2; else field = field3; } warnInvalidSSNumber(field,label); } else return true; } function daysInFebruary (year) { // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function checkDOB(field1, field2, field3) { if((field1.value==4)||(field1.value==6)||(field1.value==9)||(field1.value==11)) { if(field2.value>30) { alert("Please Select Valid Month Value"); return false; } } if(field1.value==2 && field2.value>daysInFebruary(field3.value)) { alert("Please Select Valid Day of this Month"); return false; } else { return true; } } function confirmEmailAddress(field1, field2) { if((field1.value)!=(field2.value)) { alert("The confirm email address should exactly match with email address"); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Error_ConfirmEmail"; } return false; } else { return true; } } function checkNumberStringForReferralCode(theField, cur, emptyOK) { if (checkNumberStringForReferralCode.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (!isIntegerString(theField.value)) return false; else return true; } function checkEmailForReferralCode(theField, cur, emptyOK) { if (checkEmailForReferralCode.arguments.length == 1) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isEmail(theField.value)) return false; else return true; } function checkReferralCode(field, label, emptyOK) { var numberCheck = checkNumberStringForReferralCode(field, label, emptyOK); var emailCheck = checkEmailForReferralCode(field, label, emptyOK); if ((numberCheck == true) || (emailCheck == true)) { return true; } else if (numberCheck == false) { if (emailCheck == false) { return warnInvalid(field, label); } else { return warnInvalidNumericString(field, label); } } } // Notify user that required field theField is empty. // String cur describes expected contents of theField.value. // Put focus in theField and return false. function warnEmptyCollege (theField, cur) { theField.focus(); alert(requiredCollege); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Empty_College"; } return false; } // Notify user that contents of field theField are invalid. // String c describes expected contents of theField.value. // Select theField, put focus in it, and return false. function warnInvalidSSNumber (theField, cur) { theField.focus(); theField.select(); alert(invalidSSNumberPrefix + cur + invalidSSNumberSuffix); return false; } // Notify user that required field theField is empty. // String cur describes expected contents of theField.value. // Put focus in theField and return false. function warnEmptyContactNumber (theField) { theField.focus(); alert(requiredContactNumber); if (document.getElementById("errorCode")) { document.getElementById("errorCode").value = "Empty_ContactNumbers"; } return false; } //You entered an invalid telephone number. Valid format is 999-999-9999. function checkContactNumber(field1, field2, field3, field4, field5, field6, label){ var length1 = field1.value.length; var length2 = field2.value.length; var length3 = field3.value.length; var length4 = field4.value.length; var length5 = field5.value.length; var length6 = field6.value.length; if ( length1 ==0 && length2 == 0 && length3 == 0 && length4 ==0 && length5 == 0 && length6 == 0) { warnEmptyContactNumber(field4); return false; } if ( length1 ==0 && length2 == 0 && length3 == 0) return true; if (field1.value == 0 && field2.value == 0 && field3.value == 0) { warnInvalidPhone(field1, label); return false; } if ( (length1 != 3) || (length2 != 3) || (length3 != 4) ){ if (length1 != 3) { field = field1; } else { if (length2 != 3) field = field2; else field = field3; } warnInvalidPhone(field,label); } else return true; } /* Mouse over - display info */ /*********************************************** * Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com) * Copyright 2002-2007 by Sharon Paine * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ /* IMPORTANT: Put script after tooltip div or put tooltip div just before BODY tag */ var dom = (document.getElementById) ? true : false; var ns5 = (!document.all && dom || window.opera) ? true: false; var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false; var ie4 = (document.all && !dom) ? true : false; var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false; var origWidth, origHeight; // avoid error of passing event object in older browsers if (nodyn) { event = "nope" } /////////////////////// CUSTOMIZE HERE //////////////////// // settings for tooltip // Do you want tip to move when mouse moves over link? var tipFollowMouse= true; // Be sure to set tipWidth wide enough for widest image var tipWidth= 160; var offX= 10; // how far from mouse to show tip var offY= 0; var tipFontFamily= "Verdana, arial, helvetica, sans-serif"; var tipFontSize= "8pt"; // set default text color and background color for tooltip here // individual tooltips can have their own (set in messages arrays) // but don't have to var tipFontColor= "#432A0C"; var tipBgColor= "#F48EB1"; var tipBorderColor= "#F48EB1"; var tipBorderWidth= 1; var tipBorderStyle= "ridge"; var tipPadding= 4; //////////////////// END OF CUSTOMIZATION AREA /////////////////// // preload images that are to appear in tooltip // from arrays above // to layout image and text, 2-row table, image centered in top cell // these go in var tip in doTooltip function // startStr goes before image, midStr goes between image and text //////////////////////////////////////////////////////////// // initTip - initialization for tooltip. // Global variables for tooltip. // Set styles // Set up mousemove capture if tipFollowMouse set true. //////////////////////////////////////////////////////////// var tooltip, tipcss; function initTip() { if (nodyn) return; tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null; tipcss = tooltip.style; if (ie4||ie5||ns5) { // ns4 would lose all this on rewrites tipcss.width = tipWidth+"px"; tipcss.fontFamily = tipFontFamily; tipcss.fontSize = tipFontSize; tipcss.color = tipFontColor; tipcss.backgroundColor = tipBgColor; tipcss.borderColor = tipBorderColor; tipcss.borderWidth = tipBorderWidth+"px"; tipcss.padding = tipPadding+"px"; tipcss.borderStyle = tipBorderStyle; } if (tooltip&&tipFollowMouse) { document.onmousemove = trackMouse; } } window.onload = initTip; ///////////////////////////////////////////////// // doTooltip function // Assembles content for tooltip and writes // it to tipDiv ///////////////////////////////////////////////// var t1,t2; // for setTimeouts var tipOn = false; // check if over tooltip link function doTooltip(evt, num, msg, image) { var startStr = '
' var midStr = '
'; var endStr = '
'; if (!tooltip) return; if (t1) clearTimeout(t1); if (t2) clearTimeout(t2); tipOn = true; // set colors if included in messages array var curBgColor = "#FFFFFF"; var curFontColor = "#432A0C"; if (ie4||ie5||ns5) { if (image != '') { startStr = startStr + ""; } var tip = startStr + midStr + '' + msg + '' + endStr; tipcss.backgroundColor = curBgColor; tooltip.innerHTML = tip; } if (!tipFollowMouse) positionTip(evt); else t1=setTimeout("tipcss.visibility='visible'",100); } var mouseX, mouseY; function trackMouse(evt) { standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft; mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop; if (tipOn) positionTip(evt); } ///////////////////////////////////////////////////////////// // positionTip function // If tipFollowMouse set false, so trackMouse function // not being used, get position of mouseover event. // Calculations use mouseover event position, // offset amounts and tooltip width to position // tooltip within window. ///////////////////////////////////////////////////////////// function positionTip(evt) { if (!tipFollowMouse) { standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft; mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop; } // tooltip width and height var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth; var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight; // document area in view (subtract scrollbar width for ns) var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft; var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop; // check mouse position against tip and window dimensions // and position the tooltip if ((mouseX+offX+tpWd)>winWd) tipcss.left = mouseX-(tpWd+offX)+"px"; else tipcss.left = mouseX+offX+"px"; if ((mouseY+offY+tpHt)>winHt) tipcss.top = winHt-(tpHt+offY)+"px"; else tipcss.top = mouseY+offY+"px"; if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100); } function hideTip() { if (!tooltip) return; t2=setTimeout("tipcss.visibility='hidden'",100); tipOn = false; } document.write('') function displayTerms(file) { window.open(file, "TERMS", "toolbar=no,directories=no,location=no,scrollbars=yes,width=800,height=600"); }