function validEmail(no) { var warningHeader = "The following errors occured:\n\n" var startOfWarning = " + " var incompleteWarningStart = "" var incompleteWarningEnd = " must be completed\n" var invalidEmailWarningStart = "" var invalidEmailWarningEnd = " is not a valid email address\n" var invalidNumberWarningStart = "" var invalidNumberWarningEnd = " is not a valid number \n" var invalidCheckWarningStart = " You must choose a value for " var invalidCheckWarningEnd = "\n" var displayIncomplete = "" var displayInvalid = "" var displayName = "Email" var elementValue = document.getElementById('email' + no).value; if (elementValue=="") { displayIncomplete += startOfWarning + incompleteWarningStart + displayName + incompleteWarningEnd ; } else { var locationAtSymbol = elementValue.indexOf("@") var locationLastFullStop = elementValue.lastIndexOf(".") if (locationLastFullStop <= locationAtSymbol) { displayInvalid += startOfWarning + invalidEmailWarningStart + "'" + elementValue + "'" + invalidEmailWarningEnd ; } } if (displayIncomplete.length + displayInvalid.length != 0) { alert(warningHeader + displayIncomplete + "\n" + displayInvalid) ; return false ; } else { return true ; } } function selectTab(id) { switch(id) { case 1: document.getElementById('mortgage').style.display = 'block'; document.getElementById('buytolet').style.display = 'none'; break; case 2: document.getElementById('mortgage').style.display = 'none'; document.getElementById('buytolet').style.display = 'block'; break; default: document.getElementById('mortgage').style.display = 'block'; document.getElementById('buytolet').style.display = 'none'; } }