// peintro.js // Premium Estimates On-Line // (C) 2000 NRMA Insurance Limited ABN 11 000 016 722 // Revision: 000.000.001 swang // Date: 23/03/2000 // To use this file, include the following libraries before this one is loaded in html document. // browserVersion.js - contains check for browser version // validateLib.js - contains general validation routines // ================================================================ // peintro Validation routines // ================================================================ // main functions: // function enterSuburb(value) // function enterPostcode(value) // function isSuburbEntered(msgFlag) // function isPostcodeValid(msgFlag) // function isForm1Valid(msgFlag) // function cmdSubmit1_onclick() // ================================================================= // Objects and Variables // ================================================================= // There are two objects, locationOb and vehDetailOb, corresponding to data on the forms // where location details and vehicle details are located. var standardErrorMsg = "Unfortunately, we cannot complete your "+multyBrand.premiumest+" unless you " + "answer all the questions on the page. Please make sure you have " + "answered our questions about: \n"; var form1ErrorMsg; function initialiseFieldsFromContext() { // initialise screen components setupEffectiveDate(); //Set initial focus on Date effective field document.form1.formEffectiveDay.focus(); } // =============================================================== function enterSuburb(value) { if (!isSuburbValid(value)) { alert("This field must be completed using letters. Please check your answer and try again."); document.form1.Suburb.value = ""; return false; } var firstchar = value.substring(0,1); if (firstchar == "'") { document.form1.Suburb.value = value.substring(1); } return true; } function enterPostcode(val) { if (!isPostcodeValid(val, true)) { document.form1.PostCode.value = ""; return false; } return true; } // -------------------------------------------------------- function isSuburbEntered(value, msgFlag) { if (!isContainingData(value, "Suburb", msgFlag, "")) { return false; } return true; } function isSuburbValid(value) { if (!isAlphaSpacePlus(value,"'-")) { return false; } return true; } function isPostcodeValid(postcode, msgFlag) { var risk = getRiskFromURL(); return isPostcodeValidForBrandAndRisk(postcode, msgFlag, companyName, risk, ""); } // this function uses the parameter "msgFlag" to see if error message should be // printed now or deferred until check for form 2 is completed. function isForm1Valid(msgFlag) { // check all mandatory fields contain non-empty values var errorFlag = false; form1ErrorMsg = ""; // set the parameter for message flag to false, to allow errors to be printed all at once // at the end of the check if (isEmpty(document.form1.formEffectiveDay.value)) { form1ErrorMsg += "\n\tPolicy start date"; errorFlag = true; if (first_mandatory_error === null) { first_mandatory_error = document.form1.formEffectiveDay; } } else if (isEmpty(document.form1.formEffectiveMonth.value)) { form1ErrorMsg += "\n\tPolicy start date"; errorFlag = true; if (first_mandatory_error === null) { first_mandatory_error = document.form1.formEffectiveMonth; } } else if (isEmpty(document.form1.formEffectiveYear.value)) { form1ErrorMsg += "\n\tPolicy start date"; errorFlag = true; if (first_mandatory_error === null) { first_mandatory_error = document.form1.formEffectiveYear; } } if (!isSuburbEntered(document.form1.Suburb.value, false)) { form1ErrorMsg += "\n\tSuburb"; errorFlag = true; if (first_mandatory_error === null) { first_mandatory_error = document.form1.Suburb; } } if(! isPostcodeValid_basic(document.form1.PostCode.value, false) ) { form1ErrorMsg += "\n\tPostcode"; errorFlag = true; if (first_mandatory_error === null) { first_mandatory_error = document.form1.PostCode; } document.form1.PostCode.value = ""; } if (errorFlag && msgFlag) { alert (standardErrorMsg + form1ErrorMsg); if(first_mandatory_error !== null) { first_mandatory_error.focus(); first_mandatory_error = null; } return false; } if(! isEffectiveDateFormValid()) { alert("Please check that the policy start date is correctly entered. " + "It must be a valid Day, Month and Year combination."); document.form1.formEffectiveDay.focus(); return false; } if (! isPostcodeValid(document.form1.PostCode.value, false)) { document.form1.PostCode.value = ""; return false; } return true; } function cmdSubmit_onclick() { return isForm1Valid(true); } function new_window(page) { var win = window.open(page,"_"+"blank","toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes,width=500,height=500"); } function pdsLink_onclick() { postCodeValue = document.form1.PostCode.value; //* Need this if we have different pdfs for different states e.g. NSW & QLD if (postCodeValue == null || postCodeValue.length==0 || (!isInteger(postCodeValue))) { alert('Please enter the postcode to receive the Product Disclosure Statement and Policy Wording Booklet.'); document.form1.PostCode.focus(); return; } openPDFWindow(); }