// JavaScript Document function checkCompForm() { EntrantName = document.getElementById("EntrantName").value; email = document.getElementById("email").value; TandC = document.getElementById("TandC").checked; if (EntrantName == "") { hideAllCompErrors(); document.getElementById("EntrantNameError").style.display = "inline"; document.getElementById("EntrantName").select(); document.getElementById("EntrantName").focus(); return false; } else if (email.indexOf('@') == -1 || email.indexOf('.') == -1 || email.length <7) { hideAllCompErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); document.getElementById("email").focus(); return false; } else if (TandC != 1) { hideAllCompErrors(); document.getElementById("TandCError").style.display = "inline"; document.getElementById("TandC").select(); document.getElementById("TandC").focus(); return false; } return true; } function hideAllCompErrors() { document.getElementById("EntrantNameError").style.display = "none" document.getElementById("emailError").style.display = "none" document.getElementById("TandCError").style.display = "none" } //function to check valid email address function isValidEmail(strEmail){ validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; strEmail = document.forms[0].email.value; // search email text for regular exp matches if (strEmail.search(validRegExp) == -1) { alert('A valid e-mail address is required.\nPlease amend and retry'); return false; } return true; }