//function to display a confirmation box and return the selected value. function confirmBox(strMessage) { var boolAgree=confirm(strMessage); if (boolAgree) return true ; else return false ; } //function to update specified select box with specified values. function swapOptions(objSelect, strTextArrayName,strValueArrayName) { var arrText = eval(strTextArrayName); var arrValues = eval(strValueArrayName); setOptionText(objSelect,arrText); setOptionValues(objSelect,arrValues); //objSelect.options[1].selected = true; for (c=0; c= 4) { win.window.focus(); } } function remote(URL, WIDTH, HEIGHT) { RemoteWin=window.open(URL,WIDTH+HEIGHT,"resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=auto,copyhistory=0,width=" + WIDTH + ",height=" + HEIGHT + ""); } //function to check the validity of a domain name (excluding the domain suffix). function checkDomainPrefix(strDomain) { var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; var strDomainName = new String(escape(strDomain)); var intIndex = 0; var boolValid = true; var boolInvalidChars = false; var boolInvalidHyphen = false; //Check length of domain name. if (strDomainName.length < 3) { alert("The specified domain name is too short."); boolValid = false; } if (strDomainName.length > 64) { alert("The specified domain name is too long."); boolValid = false; } //Check characters of domain name. for (intIndex = 0; intIndex < strDomainName.length; intIndex++) { if (strValidChars.search(strDomainName.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } else if(strDomainName.charAt(intIndex) == "-") { if (intIndex == 0 || intIndex == strDomainName.length - 1) { boolInvalidHyphen = true; boolValid = false; } } } if(boolInvalidChars == true) { alert("The domain name must be made up of letters, numbers and hyphens."); } if(boolInvalidHyphen == true) { alert("The domain name may not begin or end with a hyphen (-)."); } return boolValid; } //function to check that a domain suffix has been chosen. function checkDomainSuffix(objSuffixSelectBox) { var boolSelected = true; if(checkSelectBox(objSuffixSelectBox)==false) { alert("A domain suffix must be chosen from the dropdown list."); boolSelected = false; } return boolSelected; } //function to check contact details. function checkContactDetails(objSalutation, strFirstName, strSurName, strCompanyName, objCompanyType, strBuildingName, strBuildingNumber, strStreet, strTown, objCounty, strPostcode, objCountry, strTelephone, strFax, strEmail) { var boolValid = true; var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "; var strValidNumbers = "0123456789-"; var strValidTelNumbers = "0123456789 "; var strValidEmailChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.@_"; var intIndex; var boolInvalidChars; var boolInvalidHyphen; var boolInvalidSpace; var strMessage = ""; var arrEmail; //Check salutation. if(checkSelectBox(objSalutation)==false) { strMessage = strMessage + "A salutation (e.g. 'Mr') must be chosen from the dropdown list.\n"; boolValid = false; } //Check first name. if(strFirstName.length < 1) { strMessage = strMessage + "Your first name or initial must be entered in order to continue.\n"; boolValid = false; } //Check surname. if(strSurName.length < 2) { strMessage = strMessage + "Your surname must be entered in order to continue.\n"; boolValid = false; } //Check company name and type. if(strCompanyName.length > 0 && checkSelectBox(objCompanyType) == false) { strMessage = strMessage + "You must select the correct value from the type of company dropdown list.\n"; boolValid = false; } //Check building name and number if(strBuildingName.length < 3 && strBuildingNumber.length < 1) { strMessage = strMessage + "Your building name or number must be entered in order to continue.\n"; boolValid = false; } //Check building number validity. if(strBuildingNumber.length > 0) { //Check characters of number. for (intIndex = 0; intIndex < strBuildingNumber.length; intIndex++) { if (strValidNumbers.search(strBuildingNumber.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } else if(strBuildingNumber.charAt(intIndex) == "-") { if (intIndex == 0 || intIndex == strBuildingNumber.length - 1) { boolInvalidHyphen = true; boolValid = false; } } } if(boolInvalidChars == true) { strMessage = strMessage + "Your building number can only be made up of numbers and a hyphen.\n"; boolInvalidChars = false; } if(boolInvalidHyphen == true) { strMessage = strMessage + "Your building number may not begin or end with a hyphen (-).\n"; } } //Check street. if(strStreet.length < 3) { strMessage = strMessage + "Your street name must be entered in order to continue.\n"; boolValid = false; } //Check town. if(strTown.length < 3) { strMessage = strMessage + "Your town or city must be entered in order to continue.\n"; boolValid = false; } //Check county. if(checkSelectBox(objCounty) == false) { strMessage = strMessage + "You must select your county from the dropdown list.\n"; boolValid = false; } //Check postcode. if(strPostcode.length < 3) { strMessage = strMessage + "Your postcode or zipcode must be entered in order to continue.\n"; boolValid = false; } else { //Check characters of postcode. for (intIndex = 0; intIndex < strPostcode.length; intIndex++) { if (strValidChars.search(strPostcode.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } else if(strPostcode.charAt(intIndex) == " ") { if (intIndex == 0 || intIndex == strPostcode.length - 1) { boolInvalidSpace = true; boolValid = false; } } } if(boolInvalidChars == true) { strMessage = strMessage + "Your postcode can only be made up of letters, numbers and spaces.\n"; boolInvalidChars = false; } if(boolInvalidSpace == true) { strMessage = strMessage + "Your postcode may not begin or end with a space.\n"; } } //Check country. if(checkSelectBox(objCountry) == false) { strMessage = strMessage + "You must select your country from the dropdown list.\n"; boolValid = false; } //Check telephone validity. if(strTelephone.length < 6) { strMessage = strMessage + "Your telephone number must be entered in order to continue.\n"; boolValid = false; } if(strTelephone.length > 0) { //Check characters of number. for (intIndex = 0; intIndex < strTelephone.length; intIndex++) { if (strValidTelNumbers.search(strTelephone.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars == true) { strMessage = strMessage + "Your telephone number can only be made up of numbers and spaces.\n"; boolInvalidChars = false; } } //Check fax validity. if(strFax.length > 0) { //Check characters of number. for (intIndex = 0; intIndex < strFax.length; intIndex++) { if (strValidTelNumbers.search(strFax.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars == true) { strMessage = strMessage + "Your fax number can only be made up of numbers and spaces.\n"; boolInvalidChars = false; } } //Check email validity. if(strEmail.length < 6) { strMessage = strMessage + "Your email address must be entered in order to continue.\n"; boolValid = false; } if(strEmail.length > 0) { //Check characters of number. for (intIndex = 0; intIndex < strEmail.length; intIndex++) { if (strValidEmailChars.search(strEmail.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars == true) { strMessage = strMessage + "Please ensure you have entered a complete and valid email address.\n"; boolInvalidChars = false; } else { arrEmail = strEmail.split("."); if(arrEmail.length < 2) { strMessage = strMessage + "Please ensure you have entered a complete and valid email address.\n"; boolValid = false; } else { arrEmail = strEmail.split("@"); if(arrEmail.length < 2) { strMessage = strMessage + "Please ensure you have entered a complete and valid email address.\n"; boolValid = false; } } } } if(boolValid==false) {alert(strMessage);} return boolValid; } //function to check password. function checkPassword(strPassword, strConfirmPassword) { var boolValid = true; var boolInvalidChars; var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_."; //Check length of password. if(strPassword.length<4) { alert("Please enter a password for accessing the NewNet customer management interface.\nYour password must be at least 4 characters long.") boolValid = false; } //Compare password and confirmed password. if(strPassword!=strConfirmPassword) { alert("Please ensure that you correctly enter your chosen password in the password confirmation textbox."); boolValid = false; } else { //Check characters of password. for (intIndex = 0; intIndex < strPassword.length; intIndex++) { if (strValidChars.search(strPassword.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars==true) { alert("The password you have entered uses invalid characters. Please use letters and numbers only."); boolInvalidChars=false; } } return boolValid; } //function to check card details. function checkCardDetails(strCardHolder, strCardNumber, objStartMonth, objStartYear, objExpiryMonth, objExpiryYear, objCardType, strIssueNumber, strCVVCode, strTermsAgreed) { var boolValid = true; var strValidNumbers = "0123456789"; var strMessage = ""; var boolInvalidChars; var intIndex; var dteToday = new Date(); //Check card holder. if(strCardHolder.length<3) { strMessage = "The name of the card holder must be entered.\n"; boolValid = false; } //Check card number. if(strCardNumber.length<12) { strMessage = strMessage + "The full card number must be entered.\n"; boolValid = false; } else { //Check characters of card number. for (intIndex = 0; intIndex < strCardNumber.length; intIndex++) { if (strValidNumbers.search(strCardNumber.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars==true) { strMessage = strMessage + "The card number you have entered uses invalid characters. Please use numbers only with no spaces.\n"; } } //Check start date. if(objStartMonth.selectedIndex < 1 || objStartYear.selectedIndex < 1) { strMessage = strMessage + "The card start date must be entered.\n"; boolValid = false; } else { //Check that start date falls before current date. var dteStart = new Date(objStartYear.value, objStartMonth.value, 01); if(dteToday-dteStart < 0) { strMessage = strMessage + "The start date has not yet been reached.\n"; boolValid = false; } } //Check expiry date. if(objExpiryMonth.selectedIndex < 1 || objExpiryYear.selectedIndex < 1) { strMessage = strMessage + "The card expiry date must be entered.\n"; boolValid = false; } else { //Check that expiry date falls after current date. var dteExpiry = new Date(objExpiryYear.value, objExpiryMonth.value, 01); if(dteExpiry-dteToday < 0) { strMessage = strMessage + "The card has already expired.\n"; boolValid = false; } } //Check card type. if(objCardType.selectedIndex < 1) { strMessage = strMessage + "The card type must be selected.\n"; boolValid = false; } //Check issue number. if(strIssueNumber.length>1) { //Check characters of issue number. for (intIndex = 0; intIndex < strIssueNumber.length; intIndex++) { if (strValidNumbers.search(strIssueNumber.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars==true) { strMessage = strMessage + "The issue number you have entered uses invalid characters. Please use numbers only with no spaces.\n"; boolInvalidChars = false; } } //Check CVV number. if(strCVVCode.length < 3 || strCVVCode.length > 3) { strMessage = strMessage + "The CVV code for the card must be entered. \nThe CVV code is the last three digits of the number on the card signature bar.\n"; boolValid = false; } else { //Check characters of CVV number. for (intIndex = 0; intIndex < strCVVCode.length; intIndex++) { if (strValidNumbers.search(strCVVCode.charAt(intIndex)) == -1) { boolInvalidChars = true; boolValid = false; } } if(boolInvalidChars==true) { strMessage = strMessage + "The CVV code you have entered uses invalid characters. Please use numbers only with no spaces.\n"; } } if(boolValid==false) { alert(strMessage); } return boolValid; } //function to check that a value in the specified select box has been selected. function checkSelectBox(objSelectBox) { var boolSelected = true; //Check the selected index of the select box. if (objSelectBox.selectedIndex < 1) { boolSelected = false; } return boolSelected; }