function SendForm(theForm, type) { var why = ""; why += checkName(theForm.Name.value); why += checkEmail(theForm.email.value); if(type!="Email") { if(type=="Postal") why += checkAddress(theForm.Feedback.value); else if(type=="PostPhone") why += checkAddressPhone(theForm.Feedback.value); else if(type=="Sample") why += checkPhone(theForm.Phone.value) + checkAddress(theForm.Feedback.value); else if(type=="Comment") why += checkComments(theForm.Feedback.value); else if(type="catalogue"){ if(theForm.address1.value == "") why += "Please enter your address.\n"; if(theForm.suburb.value == "") why += "Please enter your Suburb.\n"; if(theForm.state.value == "") why += "Please enter your State.\n"; if(theForm.postcode.value == "") why += "Please enter your Postcode.\n"; } } if (why != "") alert(why); else theForm.submit(); } function checkEmail (strng) { var error=""; if (strng == "") { error = "You didn't enter an email address.\n"; } var emailFilter=/^.+@.+\..{2,3}$/; if (!(emailFilter.test(strng))) { error = "Please enter a valid email address.\n"; } else { //test email for illegal characters var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ if (strng.match(illegalChars)) { error = "The email address contains illegal characters.\n"; } } return error; } function checkName(strng) { var error = ""; if(strng == "") error = "Please enter your name.\n"; return error; } function checkAddress(strng) { var error = ""; if(strng == "") error = "Please enter your postal address.\n"; return error; } function checkAddress2(strng) { var error = ""; if(strng == "") error = "Please complete your postal address.\n"; return error; } function checkAddressPhone(strng) { var error = ""; if(strng == "") error = "Please enter your postal address and telephone.\n"; return error; } function checkComments(strng) { var error = ""; if(strng == "") error = "Please enter your comments.\n"; return error; } // exactly one radio button is chosen function checkRadio(checkvalue) { var error = ""; if (!(checkvalue)) { error = "Please check a radio button.\n"; } return error; } // valid selector from dropdown list function checkDropdown(choice) { var error = ""; if (choice == 0) { error = "You didn't choose an option from the drop-down list.\n"; } return error; } //Check for phone number entered function checkPhone(strng) { var error = ""; if(strng == "") error = "Please enter your telephone.\n"; return error; }