function brakeFrame(){ if(top.location != self.location){ top.location.href = document.location.href; } } function contactValidate(){ //flag for error message var flagError = 0; //for error message var errorText = "ERROR\nPlease enter\n"; //for blank enquiryComment var flagEnquiryCommentBlankError = 0; //flag for blank form var flagBlankFormError = 0; var addressCount = 0; //**********Testing for blanks in Name block**************** //to make sure a name is entered in input field if((window.document.getElementById("contactForm").name.value == "") && (window.document.getElementById("contactForm").contactPerson.value == "")) { flagError++; errorText += "Name of individual or contact person if organisation
"; } //window.document.getElementById("contactForm").businessName.value == "" //To see if anything has been entered on the form if((window.document.getElementById("contactForm").name.value == "") && (window.document.getElementById("contactForm").nameOfOrganisation.value == "") && (window.document.getElementById("contactForm").contactPerson.value == "") && (window.document.getElementById("contactForm").email.value == "") && (window.document.getElementById("contactForm").location.value == "") && (window.document.getElementById("contactForm").suggestedDates.value == "") && (window.document.getElementById("contactForm").estimatedNumberOfParticipants.value == "") && (window.document.getElementById("contactForm").threeOutcomesGoals.value == "") && (window.document.getElementById("contactForm").briefDetails.value == "")) { flagBlankFormError++; flagError++; } //************Email Block************ //To validate for valid email address var x=window.document.getElementById("contactForm") ; var Temp=x.email.value ; var EmailOk = true ; var AtSym = Temp.indexOf('@') ; var Period = Temp.lastIndexOf('.'); var Space = Temp.indexOf(' ') ; var Length = Temp.length - 1; if (((AtSym < 1) || // '@' cannot be in first position (Period <= AtSym+1) || // Must be atleast one valid char btwn '@' and '.' (Period == Length ) || // Must be atleast one valid char after '.' (Space != -1)) && // No empty spaces permitted !(window.document.getElementById("contactForm").email.value == "")) { flagError++; errorText += "Valid Email Address\n"; } //**********Output block**************** if(flagBlankFormError > 0){ errorText = "ERROR\nNothing entered on form"; } //Test to see if error message is shown if(flagError > 0){ window.alert(errorText); } //Return statements if(flagError < 1) return true; return false; }