// JavaScript Document function checkForm() { firstname = document.getElementById("firstname").value; lastname = document.getElementById("lastname").value; email = document.getElementById("email").value; if (firstname == "") { hideAllErrors(); document.getElementById("firstnameError").style.display = "inline"; document.getElementById("firstname").select(); document.getElementById("firstname").focus(); return false; } else if (lastname == "") { hideAllErrors(); document.getElementById("lastnameError").style.display = "inline"; document.getElementById("lastname").select(); document.getElementById("lastname").focus(); return false; } else if (email.indexOf('@') == -1 || email.indexOf('.') == -1 || email.length <7) { hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); document.getElementById("email").focus(); return false; } return true; } function hideAllErrors() { document.getElementById("firstnameError").style.display = "none" document.getElementById("lastnameError").style.display = "none" document.getElementById("emailError").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; }