function validateForm(form) {
  var emailRE = new RegExp(/^(\s)?(\S)+@(\S)+\.(\S)+(\s)?$/);
  if (emailRE.test(form.email_address.value) == false) {
    return errorMsg(form.email_address, "Please enter a (valid) e-mail address.");
  }
  if (form.email_body.value.length == 0) {
    return errorMsg(form.email_body, "Please enter some comments.");
  }
  return true;
}

function errorMsg(formElement, msg) {
  //Show error message (default if none specified)
  if (msg == null) msg = "There is an error with the form field '"+formElement.name+"'. Please correct this before continuing.";
  alert(msg);
  //Select and focus the invalid element
  if (formElement.select) formElement.select();
  if (formElement.focus) formElement.focus();
  //Return false to surpress form submission
  return false;
}
